خرید بک لینک

Vote count: 0

I have a struct which I am trying to Marshal which is defined as follows:

enum BBB {BB1 =1, BB2 =2}

  [StructLayout(LayoutKind.Sequential, Pack = 1)]
  struct Foo 
  {
     [MarshalAs(UnmanagedType.I2)]
     public BBB F1;
     public int F2;
     public short F3;
  }

Seems like Marshal can't handle this enum field specification and throws an exception: caot be marshaled as an unmanaged structure; no meaningful size or offset can be computed. If I remove the [MarshalAs(UnmanagedType.I2)], then marshaling succeeds, but I would like to be able to marshal an enum field as a custom size field not necessarily a 4 byte one.

Has anyone run into this issue?

asked 21 secs ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 5 مرداد 1395 ساعت: 4:15

صفحه بندی