all groups > dotnet interop > march 2005 >
You're in the

dotnet interop

group:

Variant containing SAFEARRAY problems


Variant containing SAFEARRAY problems Andrew S. Giles
3/30/2005 2:11:03 PM
dotnet interop:
Helllo all,

I have a COM server that exposes an explicit interface that has a method
that accepts a VARIANT datatype. I want to use this to pass arrays of
integers/doubles/BSTR from my C++ app to a separate C# application.

I can move individual int, double, BSTR without a problem.

But when I try to utilize the VARIANT, I run into problems. The only one
that works is the VARIANT which contains a SAFEARRAY, and I code the Variant
type (vt) to VT_I4 | VT_ARRAY.

If I use VT_R8 | VT_ARRAY or VT_BSTR | VT_ARRAY to send Arrays of doubles or
strings, for some reason the Event that is raised when the method is called
does not get the control (I dont stop at the breakpoint).

Does anyone have any idea qhy this might be happening?

Thanks in advance,

RE: Variant containing SAFEARRAY problems Andrew S. Giles
3/31/2005 8:25:12 AM
Just as an update...

I have called the same method from the C# side (explicit call to the COM
server) with an Array of doubles, and it gets Marshalled to a VARIANT for the
COM server just fine. I can look at it there, and all seems correct (VT =
8197 = VT_R8 | VT_ARRAY).

However, double checking the double array int he VARIANT from the C++ side
shows the same vt (8197) but the event raised is not caught.

Has anyone else heard of such a thing, or can anyone point me to a place
where I might get more information to fix this?

[quoted text, click to view]
AddThis Social Bookmark Button