August 2003
Intermediate to advanced
736 pages
14h 48m
English
The types that hold the data are always subject to the .NET rules of versioning,[4] but that doesn't really help you when it comes to reading and writing old versions of the data using new versions of the object. One way to support versioned data formats is to write a version ID into the stream as part of a custom implementation of ISerializable:
[4] The details of .NET type versioning are covered in Essential .NET (Addison-Wesley, 2003), by Don Box, with Chris Sells.
[SerializableAttribute] class MyData : ISerializable { string s = "Wahoo!"; int n = 6; ArrayList oldStrings = new ArrayList(); // v2.0 addition static string currentVersion = "2.0"; ... #region Implementation of ISerializable public MyData( SerializationInfo info, ...
Read now
Unlock full access