Groups | Blog | Home
all groups > dotnet interop > october 2005 >

dotnet interop : Passing array of IUnknowns from unmanaged to managed


John Lutz
10/21/2005 9:43:02 AM
I need to implement a COM interface in VB.NET and C#.NET. The interface has
the following method:

void SetObjects([in] SAFEARRAY(LPUNKNOWN) objects);

In other words, I need to pass an array of IUnknown pointers to VB or C#.

I can change the interface however I want. My goal is to make the managed
code as simple as possible, i.e., receive an ArrayList if possible.

How should I define SetObjects in my IDL?
What is the corresponding method declaration in VB and C#?

John Lutz
10/21/2005 11:06:02 AM
Thanks, I had a typo in my code. Your sample helped me see it.

[quoted text, click to view]
Robert Jordan
10/21/2005 7:12:22 PM
John,

[quoted text, click to view]

C#:

void SetObjects(
[In]
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_UNKNOWN)]
object[] objects
);


The marshal attribute is probably not necessary.

AddThis Social Bookmark Button