Marshal safearray of struct inside struct

前端 未结 2 1917
遥遥无期
遥遥无期 2021-01-19 19:21

I have the following code in C++ which I need to be able to call from C#:

struct Inner
{
 double data1;
 double data2;
};

struct Outer
{
 double data3;
 SAF         


        
2条回答
  •  Happy的楠姐
    2021-01-19 19:51

    It looks as if the attribute declaration is not correct as its refusing to compile...

    [StructLayoutAttribute(LayoutKind.Sequential)]
            public struct Outer
            {
                public double data3;
                [MarshalAsAttribute(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_SAFEARRAY)]
                public Inner[] innerData;
            }
    

    Hope this helps, Best regards, Tom.

提交回复
热议问题