i'm working on a finger print module, the compiler throw me an unhandled exception with no details or data for what's wrong
An unhandled exception of type 'System.Exception' occurred in Project Intersect.exe
public static implicit operator byte[](CommandPacket packet) { var buffer = new byte[52]; fixed (byte* ptr = buffer) { *((ushort*)(ptr)) = (ushort)packet.PacketID; *((ushort*)(ptr + 2)) = (ushort)packet.Subtype; *((ushort*)(ptr + 4)) = packet.Length; for (var i = 0; i < 16; i++) *(ptr + 6 + i) = packet.Data[i]; *((ushort*)(ptr + 22)) = packet.CheckSum; } return buffer; }
it throws the exception at *((ushort*)(ptr)) = (ushort)packet.PacketID; (yeah i did try to comment this one as maybe it could be the enum casting that causes this problem but still same exception on the next line)
so what's wrong ? any alternatives ?