473,405 Members | 2,373 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,405 software developers and data experts.

Deserializing after class has been modified.

Hi

am trying to find a way to backward support serialized files of older version

Example:
Given a class

class MyClass
{
int a;
int b;
}

Serialize MyClass using SoapFormatter to myclass.bin

add int c; to MyClass

class MyClass
{
int a;
int b;
int c;//newly added
}

If i deserialize using SoapFormatter now from myclass.bin (created before
adding int c)... exception will thrown..

is there anyway to support 'older' version of serialized soap files besides
manually parsing it?

many thanks
tham
Nov 16 '05 #1
2 1415
In .NET 1.1 you can't (well there's a trick, keep reading).
In .NET 2.0 Soapformatter you're out of luck, BinaryFormatter will work
using an new OptionalAttribute.

You can get this behavior by implementing ISerialization in .NET 1.1 and use
reflection to read stuff out of the SerializationInfo info variable.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
"tham" <th**@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...
Hi

am trying to find a way to backward support serialized files of older version
Example:
Given a class

class MyClass
{
int a;
int b;
}

Serialize MyClass using SoapFormatter to myclass.bin

add int c; to MyClass

class MyClass
{
int a;
int b;
int c;//newly added
}

If i deserialize using SoapFormatter now from myclass.bin (created before
adding int c)... exception will thrown..

is there anyway to support 'older' version of serialized soap files besides manually parsing it?

many thanks
tham

Nov 16 '05 #2
Sorry that was ISerializable.
"Sahil Malik" <co*****************@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
In .NET 1.1 you can't (well there's a trick, keep reading).
In .NET 2.0 Soapformatter you're out of luck, BinaryFormatter will work
using an new OptionalAttribute.

You can get this behavior by implementing ISerialization in .NET 1.1 and
use
reflection to read stuff out of the SerializationInfo info variable.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
"tham" <th**@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...
Hi

am trying to find a way to backward support serialized files of older

version

Example:
Given a class

class MyClass
{
int a;
int b;
}

Serialize MyClass using SoapFormatter to myclass.bin

add int c; to MyClass

class MyClass
{
int a;
int b;
int c;//newly added
}

If i deserialize using SoapFormatter now from myclass.bin (created before
adding int c)... exception will thrown..

is there anyway to support 'older' version of serialized soap files

besides
manually parsing it?

many thanks
tham


Nov 16 '05 #3

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

Similar topics

1
by: Justin Armstrong | last post by:
I'm having difficulties deserializing some objects. Consider the following example of what I'm trying to do: ---------------------------------------------------------- class Person { string...
1
by: Thomas | last post by:
Hi, I implemented a composite pattern which should be serializable to xml. After spending some time in the newsgroups, i finally managed serializing, even with utf-8 instead of utf-16, which...
3
by: Mark McConnell | last post by:
Regarding deserializing XML into a custom object... I've been able to deserialize an XML doc into my custom object and everything works great. The problem I am encountering is when one of the...
1
by: elixxir | last post by:
Hiho, I'm trying to deserialize the following XML feed from the weather channel but I'm having an issue with the nested arrays. I got as far as getting the 'day' into arrays but I can't get the...
4
by: Wayne Wengert | last post by:
Using VB.NET I want to read in an XML file that has an array of objects and then step through the resulting array in code. I build a class to define the structure and I am running code to read in...
2
by: Earl Teigrob | last post by:
I am saving and restoring value types such as Int32, DateTime and Boolean in strings. I was wondering if there is a mechanism build into .NET for serializing and deserializing these to string...
1
by: Bob Rock | last post by:
Hello, always having to validate an XML stream against a XSD may add up an important overhead. My XMLs are usually the result of serializing a class instance and often in my applications what I...
6
by: Steve Teeples | last post by:
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...
1
by: =?Utf-8?B?SmVyZW15X0I=?= | last post by:
I am working on an order entry program and have a question related to deserializing nodes with nested elements. The purchase order contains multiple line items which I select using an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.