My struct as follow:
[StructLayout(LayoutKind.Sequential , Pack = 1)]
public struct person
{
[MarshalAs(UnmanagedType.ByValArray,SizeConst = 64)]
public char[ ] name;
public uint id;
public float action;
public commandMessage (string _userName, uint _id, float _action)
{
this.name = _userName.PadRight (64,‘\0’).ToCharArray ();
this.id = 0;
this.action = 0.0f;
}
};
I need to convert this struct to an byte array:
int size = Marshal.SizeOf(obj);
byte[ ] bytes = new byte;
IntPtr structPtr = Marshal.AllocHGlobal(size);
Marshal.StructureToPtr (obj, structPtr, false);
when my project run to :
Marshal.StructureToPtr (obj, structPtr, false);
I get error:
Attempting to JIT compile method ‘(wrapper runtime-invoke)
****:runtime_invoke_void_object_intptr_bool (object,intptr,intptr,intptr)’ while running with --aot-only.
Please help!