Can anyone tell me how to get data from a byte array into the following
structure?
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct MESSAGE_LOG_HEADER_STRUCT2
{
public DateTime dtTimeStamp;
public Int32 dSerialNumber;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=8)]
public byte[] strMCFirmwareVersion;
public Int32 dMCFirmwareChecksum;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=8)]
public byte[] strSBCSoftwareVersion;
public Int32 dSBCSoftwareChecksum;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=32)]
public byte[] strBarcode;
}
I have tried the following code, but I get the exception "BinaryFormatter
Version incompatibility." when it executes.
MemoryStream ms = new MemoryStream(bytes); // bytes is a byte[]
BinaryFormatter bf = new BinaryFormatter();
m_CompleteIllumStateMsg = (MIX_CompleteIllumStateMsg)bf.Deserialize(ms); //
m_CompleteIllumStateMsg is a MESSAGE_LOG_HEADER_STRUCT2