Version tolerant (de)serialization

Topics: Caching Application Block
May 23, 2008 at 3:17 AM
Edited May 23, 2008 at 3:19 AM

One sticky point with Caching Application Block is when new build of app is released and the cache does not match the new definition in the assembly.  Even if only one private field in the entire cache has different type definition, entire cache is for scraps.

In .NET 2.0 great strives have been made to make binary serialization more version tolerant, with new or removed fields no longer throwing exceptions.  Although one scenario that keeps throwing an exception... when the type of a field has changed.  Using OptionalFieldAttribute one can indicate to omit during deserialization a new field, if the data for that field is not present in the old stream. 

Is there any declarative (such as TypeConverterAttribute) or imperative mechanism to handle situations when the type of the field has changed, to prevent exception from throwing when data type of one or more fields has changed?  Essentially to ignore reading data for fields that have different type between definition in old serialized stream and new definition in assembly.

Thanks in advance