The NETMF Serialization support is made to be lean and it is not compatible with the PC. I remember ages ago that someone wrote PC code that understands NETMF’s serialized object and did de-serialize them on the PC.
Any veteran remembers this and who wrote that code?
ARTICLE COPIED TEXT:
Downloading the Data download SAMPLE
The .NET Micro Framework allows us to easily serialize the SwimTimingCollection via the Serializable attribute. My helper class TimeSpanFormatter and the reference to the owning collection should not be serialized; this is accomplished by marking them with NonSerialized attributes.
[Serializable]
public class SwimTiming : IComparable
{
int _Number;
DateTime _TimeStart;
TimeSpan _Elapsed;
[NonSerialized]
SwimTimingCollection _List;
...
}
[Serializable]
public class SwimTimingCollection : ArrayList
{
int Counter = 0;
[NonSerialized]
TimeSpanFormatter _TimeSpanFormatter;
...
}
Transferring data is accomplished by the Upload method. For our needs, the serial port is fast enough, since the timing table is fairly small. However, it is possible to use another port if better performance is needed.
private void Upload()
{
SerialPort.Configuration config = new SerialPort.Configuration(
SerialPort.Serial.COM1, SerialPort.BaudRate.Baud19200, false);
SerialPort port = new SerialPort(config);
byte[] Blob = Reflection.Serialize(_SwimTimings,
typeof(SwimTimingCollection));
port.Write(Blob, 0, Blob.Length);
port.Dispose();
}
On the PC end, we will need to decode the .NET Micro Framework’s binary serialization format, which is designed to keep the data as small as possible. It would be not much more work to generate XML instead, if desired, by concatenating strings and generating a byte array (using the UTF8Encoding class) to be passed on to the SerialPort.Write() method.