Deserialization of changed objects

  • Thread starter Thread starter Urs Vogel
  • Start date Start date
U

Urs Vogel

Hi

Let's assume that I have an object_V1 (version 1) serialized to disk. Later,
the class for object_V1 will change to object_V2, having some more members.
Now, I would like to read my previously saved objects of type object_V1 into
object_V2, which (logically) now throws an exception.

I tried to make use of the HeaderHandler, but this gives me only access to
the methods, not the members. I also tried to inherit object_V1 into
object_V2, which didn't work either.

Is there an way to control this deserialization process, any samples around?

Any hints ar appreciated.

Thanks. Urs.
 
You would have to implement ISerializable in Object_V2.

Object_V2, GetObjectData - would serialize, and the protected
new(Serialization Info, StreamingContext context) would deserialize (hope my
memory is holding up to the exact param list ... it's been a while since I
did this.

So the V2 - V1 members would get a default value assignment in this New
function.

_ Sahil Malik
Independent Consultant.
 
Back
Top