all groups > dotnet interop > february 2008 >
You're in the

dotnet interop

group:

Return .NET array of objects to COM


Return .NET array of objects to COM RF
2/29/2008 4:00:03 AM
dotnet interop: Hi,

I'm trying to create a C# dll that will return an array of objects.

SomeObj[] Func(){...}

The object in question is exposed to COM and I can create it in VB6 with no
problem.

When i look at the type library it shows me that the return type is an array
of the object in question but when I do the call I get a Type Mismatch in VB

Dim arr() as SomeObj

SomeObj = Func()

I tried this instead:
Dim arr as Variant
arr = Func()

This does not generate an error and it sees that it's an array but each
element is defined as unknown type definition.

We defined this in C#

SomeObj Func() {...}

and it works fine.

So why is the array not being marshaled properly

RE: Return .NET array of objects to COM Adam
3/29/2008 11:10:00 PM
RF,

I haven't worked in this area specifically, but arrays in COM are generally
passed as SafeArrays, so you might start there.

[quoted text, click to view]

I'm surprised this didn't work.. but then, I don't know VB6/COM.

Adam

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