Cross Version Serialization Broken between V1.1 and V2.0 [Ryan Byington]

Cross Version Serialization Broken between V1.1 and V2.0 [Ryan Byington]

  • Comments 4

In V2.0 we sometimes needed to add fields to types that existed in V1.1. If this type just has the Serializable attribute applied to it this will break serialization compatibility with V1.1. Currently when 1.1 tries to deserialize an instance with this new field it will throw an exception the runtime formatters do not allow for missing or additional fields.

 

We fixed this in V2.0 by adding the OptionalFieldAttribute which allows type authors to mark new fields as optional. This attribute would be applied to a field that was added in a newer version of the type. With this backwards and forwards serialization compatibility is maintained. 

 

However V1.1 and even V1.1 SP1 are still currently broken since the strict formatter behavior has not changed. This will likely be fixed in SP2 but until then don’t expect cross version serialization to work.

 

Some pretty fundamental types are affected by this like CompareInfo and any types like System.Collections.Comparer that have a field of this type. Which means Hashtable is broken as well.

  • Tips
  • This was already an issue between V1.0 and V1.1 (e.g. with Hashtable), as I remember. I'm a bit disappointed it takes MSFT so long (until 1.1 SP2) to learn this lesson...
  • Tips
  • .NET Framework V1.1でSerializeしたイメージはV2.0で読めない
Page 1 of 1 (4 items)