473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Broken serialization

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);

Jun 20 '06 #1
2 1819
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);

Jun 20 '06 #2
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" <PR****@newsgroups.nospam> wrote in message
news:F7**********************************@microsof t.com...
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=

Jun 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Aaron Clamage | last post by:
Hi, I'm not sure that if this is the right forum, but any help would be greatly appreciated. I am porting some java serialization code to c# and I can't figure out the correct way to do it. ...
3
by: Alexander | last post by:
When i store rule on PC with .NET.SP1 i cant restore them from PC without SP1. An i get this Error: System.Runtime.Serialization.SerializationException: Possible Version mismatch. Type...
5
by: Dave | last post by:
Hello All, A couple of weeks ago, I undertook to write a utility that would loop through various URLs and test whether they were valid. I got some good help from this list, and was able to...
64
by: groups | last post by:
C# is an impressive language...but it seems to have one big limitation that, from a C++ background, seems unacceptable. Here's the problem: I have a third-party Document class. (This means I...
4
by: mijalko | last post by:
Hi, I have inherited my class from System.Drawing.Printing.PrintDocument and I wish to serialize this object using XmlSerializer. And I get exception "There was an error reflecting type ...". If I...
5
by: Nikola Skoric | last post by:
I ran in Mono a program developed on .NET Framework 2.0 and it ran OK until I tried to desirialize a object. There the program died abruptly dumping this: System.ArgumentOutOfRangeException:...
0
by: bharathreddy | last post by:
Before going to that i want to say few thing on serialization : Serialization is the process of converting an object into a form that can be readily transported. For example, you can serialize an...
2
by: mkvenkit.vc | last post by:
Hello, I hope this is the right place to post a question on Boost. If not, please let me know where I can post this message and I will do so. I am having a strange problem with std::string as...
8
by: Andy B | last post by:
I have the following code in a default.aspx web form page_load event. There seems to be a problem with line 5 (NewsArticle.Date = line). //create a news article NewsArticle NewsArticle = new...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.