Marshal safearray of struct inside struct

前端 未结 2 1870
遥遥无期
遥遥无期 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条回答
  •  旧时难觅i
    2021-01-19 19:42

    Did you try this?

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

提交回复
热议问题