Raghav55
Raghav55

Reputation: 3135

Object Serialization

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

Upvotes: 2

Views: 550

Answers (3)

Jon Arnar
Jon Arnar

Reputation: 11

.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/

Upvotes: 0

Muhammad Hasan Khan
Muhammad Hasan Khan

Reputation: 35126

Read Version Tolerant Serialization

Upvotes: 4

Mirko
Mirko

Reputation: 4282

Generally add a version and implement custom serialization via ISerializable.

Handle appropriate defaults and or throw more appropriate exceptions there.

See here

Upvotes: 0

Related Questions