Disclaimer: Near zero with marshalling concepts..
I have a struct B that contains a string + an array of structs C. I need to send this across the giant interop chasm to a COM - C++ consumer.
What are the right set of attributes I need to decorate my struct definition ?
[ComVisible (true)]
[StructLayout(LayoutKind.Sequential)]
public struct A
{
public string strA
public B b;
}
[ComVisible (true)]
[StructLayout(LayoutKind.Sequential)]
public struct B
{
public int Count;
[MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.Struct, SizeParamIndex=0)]
public C [] c;
}
[ComVisible (true)]
[StructLayout(LayoutKind.Sequential)]
public struct C
{
public string strVar;
}
edit: @Andrew Basically this is my friends' problem. He has this thing working in .Net - He does some automagic to have the .tlb/.tlh created that he can then use in the C++ realm. Trouble is he can't fix the array size.