how does serialization handle versions?
-
in c++ when i would serialize an object i would always put a version as the second string serialized.. then when i deserialized i would read that version and read in the rest of the data based on what version the file was, in case variables had been added/removed between that version and the current version. how does C# handle this? it seems like it serializes and deserializes in its own way.. how do i handle multiple versions of an object when serializing? still a newb.. cut me some slack :P -dz
-
in c++ when i would serialize an object i would always put a version as the second string serialized.. then when i deserialized i would read that version and read in the rest of the data based on what version the file was, in case variables had been added/removed between that version and the current version. how does C# handle this? it seems like it serializes and deserializes in its own way.. how do i handle multiple versions of an object when serializing? still a newb.. cut me some slack :P -dz
dazinith wrote: how does C# handle this? Very poorly IMHO. If the structure/class has changed between versions then you will get an exception thrown when it tries to deserialize the object. There is currently a problem if you serialized a
Hashtable
in version 1.0 of the framework and try to deserialize thatHashtable
in version 1.1. The cause is that MS added a new member to theHashtable
in the new version. I do not know what would happen if you implementISerializable
to do as you mentioned (storing aVersion
object and have your deserialization code fromISerializable
use thatVersion
object to read back the correct data). Perhaps this would make a good article :) dazinith wrote: still a newb.. cut me some slack We all were at one time or another ;) James "It is self repeating, of unknown pattern" Data - Star Trek: The Next Generation