C#.NET COM interoperability: Arrays of UDT's in COM

R

Raj

Hi,

This is regarding using Arrays of UDT's in COM.

The following is a short description:

- We basically need a structure, struct MAIN_STRUCT which must contain a
dynamic array of another struct, struct SUB_STRUCT. We have a interface
function that is callable by the client, which takes a dynamic array of
MAIN_STRUCT as parameter. So the problem is wrt passing around dynamic
arrays of structs(UDT's) that further contains a dynamic array of another
struct(UDT) in it (from the COM server side).

- We can use SAFEARRAY(struct) but this works only for a simple struct. It
does not appear possible to create SAFEARRAYS(structs) that contain another
struct inside it.

- The other problem is wrt interoperability as we have a (unmanaged)legacy
ATL-COM server whereas a C#.NET client at the other end

Please let me know if you have any suggestions/comments/workarounds for this
problem

Thanks,
Raj
 
N

Nicholas Paldino [.NET/C# MVP]

Raj,

If you use a safearray for the dynamic array of sub structures, then it
should marshal just fine.

Can you show the definitions of the structures you are using?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top