Can anyone tell me how to get data from a byte array into the following
structure?
[Serializable]
[StructLayout(La youtKind.Sequen tial)]
public struct MESSAGE_LOG_HEA DER_STRUCT2
{
public DateTime dtTimeStamp;
public Int32 dSerialNumber;
[MarshalAs(Unman agedType.ByValA rray, SizeConst=8)]
public byte[] strMCFirmwareVe rsion;
public Int32 dMCFirmwareChec ksum;
[MarshalAs(Unman agedType.ByValA rray, SizeConst=8)]
public byte[] strSBCSoftwareV ersion;
public Int32 dSBCSoftwareChe cksum;
[MarshalAs(Unman agedType.ByValA rray, SizeConst=32)]
public byte[] strBarcode;
}
I have tried the following code, but I get the exception "BinaryFormatte r
Version incompatibility ." when it executes.
MemoryStream ms = new MemoryStream(by tes); // bytes is a byte[]
BinaryFormatter bf = new BinaryFormatter ();
m_CompleteIllum StateMsg = (MIX_CompleteIl lumStateMsg)bf. Deserialize(ms) ; //
m_CompleteIllum StateMsg is a MESSAGE_LOG_HEA DER_STRUCT2
structure?
[Serializable]
[StructLayout(La youtKind.Sequen tial)]
public struct MESSAGE_LOG_HEA DER_STRUCT2
{
public DateTime dtTimeStamp;
public Int32 dSerialNumber;
[MarshalAs(Unman agedType.ByValA rray, SizeConst=8)]
public byte[] strMCFirmwareVe rsion;
public Int32 dMCFirmwareChec ksum;
[MarshalAs(Unman agedType.ByValA rray, SizeConst=8)]
public byte[] strSBCSoftwareV ersion;
public Int32 dSBCSoftwareChe cksum;
[MarshalAs(Unman agedType.ByValA rray, SizeConst=32)]
public byte[] strBarcode;
}
I have tried the following code, but I get the exception "BinaryFormatte r
Version incompatibility ." when it executes.
MemoryStream ms = new MemoryStream(by tes); // bytes is a byte[]
BinaryFormatter bf = new BinaryFormatter ();
m_CompleteIllum StateMsg = (MIX_CompleteIl lumStateMsg)bf. Deserialize(ms) ; //
m_CompleteIllum StateMsg is a MESSAGE_LOG_HEA DER_STRUCT2
Comment