mscorlib::_Array

Hello All,

I have followed the documentation on COM Interop. I have declared a method on a class and exposed it to COM. This method has a parameter of the type System.Array. When I write a COM client to use the "marshalled" version of the System.Array (mscorlib::_Array), the definition for this interface is blank!!

struct __declspec(uuid("2b67cece-71c3-36a9-a136-925ccc1935a8"))
_Array : IDispatch
{};

Any ideas what I am doing wrong? Or is it a bug?

If I choose MashalAs this then puts it as a SAFEARRAY...

Thanks in advance.
Cheers,
Darren.

[673 byte] By [DarrenStones] at [2008-2-21]
# 1

What you're seeing is correct. By default managed interfaces are exposed this way for versioning reasons. If you really want your unmanaged code to call the methods of System.Array, you'll need to invoke them on the _Array interface via IDispatch. (The methods are really there, you just can't see them in the type library.)

But typically people do want the System.Array to be marshalled as a SAFEARRAY since that's what COM (including VB6) works well with. I'm guessing you're using a generic System.Array instead of a strongly-typed array because you want variable dimensions or lower bounds? A SAFEARRAY can express all those things and the marshaling should work just fine.

Adam_Nathan at 2007-9-9 > top of Msdn Tech,.NET Development,Common Language Runtime...

.NET Development

Site Classified