Marshaling C++ struct with fixed size array into C#

前端 未结 1 900
闹比i
闹比i 2021-01-06 04:42

I have a C# struct declared like so:

public struct AdvertisementData {
    public byte SomeId;
    [MarshalAs(UnmanagedType.LPArray , SizeConst = 12)]
    pu         


        
相关标签:
1条回答
  • 2021-01-06 05:18

    Try to marshal it as ByValArray:

     [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
      public byte[] AnArray;
    

    And also, are you sure that you do not need to set any LayoutKind for your struct?

    0 讨论(0)
提交回复
热议问题