Deserializing data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I use serialization to write class data to a file. During my development of
this class I need to add properties or fields on occation. After adding a
property, when deserializing the data saved to disk I get an exception error
indicating that the class data members no longer match.

To avoid the exception errors, how can I retrieve data from the disk and
populate the existing fields found within the file and set defaults for the
new properties that I've created?
 
I may have missed something while reading the article but it doesn't seem to
answer my question. What happens if I add an new field to my class after
data has been serialized to a file. When reading the old serialized data
back into my "new" class I get an exception error because the fields no
longer match. Currently I'm using BinaryFormatter, not xml.
--
Steve


AMALORPAVANATHAN YAGULASAMY(AMAL)MCP said:
Refer the following article,
http://www.microsoft.com/india/msdn/articles/228.aspx
--
Regards,
Amal [MCP, MCS]
http://geocities.com/techsharing


Steve Teeples said:
I use serialization to write class data to a file. During my development of
this class I need to add properties or fields on occation. After adding a
property, when deserializing the data saved to disk I get an exception error
indicating that the class data members no longer match.

To avoid the exception errors, how can I retrieve data from the disk and
populate the existing fields found within the file and set defaults for the
new properties that I've created?
 
I have and am using it on serveral fields that do not require serialization.
However, the addition of some fields will require serialization and therefore
must be serialized. Older versions will not understand the new field when
deserializing. Is there a way to ignore the fact that a new field exists
when deserializing?
 
Ok. Now i see the actual problem. I dont know of any in-built mechanism
to do this. AFAIK, the idea Fred has suggested in the other thread
seems to be the best.
 
Back
Top