Object Serialization

555 Views Asked by At

Assume object A has 6 fields, now the object A is serialized, after some time the 3 more fields are added and the object is deserialized.

  1. Adding of the new fields will create any exception when deserializing.
  2. How to have a backward compatibility
3

There are 3 best solutions below

0
On

Generally add a version and implement custom serialization via ISerializable.

Handle appropriate defaults and or throw more appropriate exceptions there.

See here

0
On
1
On

.Net has something called "Version Tolerant Serialization" ;)

Check out this easy to understand example on object serialization:

http://programming.flashadventures.com/c-sharp/writing-objects-to-files-serialization/