Marshal.PtrToStructure in iPhone makes error.

Hi!

I have been working with it for over 3 days.

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public class Header
{
public ushort psize;
public ushort cmd;
public uint sequenceNum;
}

IntPtr p = GetDataFromNative();
Header h = new Header();

h = (Header)Marshal.PtrToStructure(p, typeof(Header));

Marshal.PtrToStructure makes following error.
Unhandled Exception: System.ExecutionEngineException: Attempting to JIT compile method ‘(wrapper unknown) Header:StructureToPtr (object,intptr,bool)’ while running with --aot-only.)

How can I solve that problem ?
Please Help me…

Best Regards,
Adam.

Try switching from class to struct.