PC Review


Reply
Thread Tools Rate Thread

Broken serialization

 
 
Chukkalove
Guest
Posts: n/a
 
      20th Jun 2006
I've had to change a class within an application.
The previous developer used serialization to store objects to file. He didnt
use ISerializable interface and even if he had.....
I just dont trust or like using serialization just for the reasons Im asking
for help about.
He used binary serialization, and Im getting errors when the file is read
from disk as the class has changed.
I need to be able to read files created with previous versions of this
software.

I added IDeserializable to try to diagnose the problem, but the deserialize
call fails at bfSkin.Deserialize and my callback to OnDeserialization is
never called.
Is there anything that i can do to step through the deserialization of my
object so that I could at least have a go at fixing it please?


FileStream fsSkin = new FileStream(sFileName, FileMode.Open);

BinaryFormatter bfSkin = new BinaryFormatter();

// Deserialize the object graph

rSkinFile=null;

try

{

rSkinFile = (SkinFile) bfSkin.Deserialize(fsSkin);



 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgUml0Y2hpZQ==?=
Guest
Posts: n/a
 
      20th Jun 2006
You only really need to implement ISerializable if you want to perform custom
serialization. Applying SerializableAttribute to your class is generally
enough for most people.

Check out Version Tolerant Serialization. You should get some good
resources with the following google search:
http://www.google.ca/search?hl=en&q=...lization&meta=

--
http://www.peterRitchie.com/


"Chukkalove" wrote:

> I've had to change a class within an application.
> The previous developer used serialization to store objects to file. He didnt
> use ISerializable interface and even if he had.....
> I just dont trust or like using serialization just for the reasons Im asking
> for help about.
> He used binary serialization, and Im getting errors when the file is read
> from disk as the class has changed.
> I need to be able to read files created with previous versions of this
> software.
>
> I added IDeserializable to try to diagnose the problem, but the deserialize
> call fails at bfSkin.Deserialize and my callback to OnDeserialization is
> never called.
> Is there anything that i can do to step through the deserialization of my
> object so that I could at least have a go at fixing it please?
>
>
> FileStream fsSkin = new FileStream(sFileName, FileMode.Open);
>
> BinaryFormatter bfSkin = new BinaryFormatter();
>
> // Deserialize the object graph
>
> rSkinFile=null;
>
> try
>
> {
>
> rSkinFile = (SkinFile) bfSkin.Deserialize(fsSkin);
>
>
>
>

 
Reply With Quote
 
Chukkalove
Guest
Posts: n/a
 
      20th Jun 2006
Thanks for replying Peter
I'll never use serialization by choice. Was bitten before and there are
other ways to do a similar job.
My problem is that I need to be able to find some way to open and convert
files previously written with the serialization that's now broken because
its been very necessary to change the object.

thanks





"Peter Ritchie" <(E-Mail Removed)> wrote in message
news:F7014FB9-AFB2-47EA-80B1-(E-Mail Removed)...
> You only really need to implement ISerializable if you want to perform
> custom
> serialization. Applying SerializableAttribute to your class is generally
> enough for most people.
>
> Check out Version Tolerant Serialization. You should get some good
> resources with the following google search:
> http://www.google.ca/search?hl=en&q=...lization&meta=



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lots of problems - regedit is broken, taskbar is misbehaving, audio is broken.. HELP! Elspeth Windows Vista General Discussion 3 2nd Jul 2008 11:19 PM
Recursive XML serialization? XML serialization of cyclic objects? =?ISO-8859-1?Q?=22Andr=E9s_G=2E_Aragoneses_=5B_kno Microsoft C# .NET 2 16th Jan 2007 03:52 PM
Serialization and de-serialization of types loaded from assembly at runtime mookid8000@gmail.com Microsoft C# .NET 6 1st Mar 2006 09:27 AM
Search broken...extended views broken. =?Utf-8?B?TWFyayBCb3dsZXM=?= Windows XP Help 1 21st Sep 2005 06:59 AM
Broken address toolbar and broken run dialog Daniel Bond Windows XP Networking 0 11th Aug 2003 02:13 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:38 AM.