- Home /
Help Marshal.StructureToPtr only IOS platform problem
if i use UnmanagedType.ByValArray in my c# code.
i have some problem.
this code well in Mac and Android.
but, if i build on IOS platform (like iPhone, iPAD) it will be exception.
function : 'Marshal.StructureToPtr' error message : Attempting to JIT compile method '(wrapper unknown) MTD_TEST:StructureToPtr(object,intptr,bool)
[StructLayout(LayoutKind.Sequential, Pack=1)]
public struct MTD_TEST {
public ushort msgTypes;
public int linkIndex;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4, ArraySubType = UnmanagedType.U1)]
public byte[] pDataBufs;
};
int len = Marshal.SizeOf(obj);
byte [] arr = new byte[len];
IntPtr ptr = Marshal.AllocHGlobal(len);
Marshal.StructureToPtr((T)obj, ptr, false);
Marshal.Copy(ptr, arr, 0, len);
Marshal.FreeHGlobal(ptr);
Comment
Your answer
Follow this Question
Related Questions
How to identify each iOS device? 1 Answer
Xcode build crashes 0 Answers
How to test on iOS simulator? 1 Answer
ARkit objects not showing up on phone 0 Answers