PC Review


Reply
Thread Tools Rate Thread

Deserializing after class has been modified.

 
 
=?Utf-8?B?dGhhbQ==?=
Guest
Posts: n/a
 
      5th Jan 2005
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
 
Reply With Quote
 
 
 
 
Sahil Malik
Guest
Posts: n/a
 
      5th Jan 2005
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" <(E-Mail Removed)> wrote in message
newsE4F518A-34C5-4EDD-A7E5-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Sahil Malik
Guest
Posts: n/a
 
      9th Jan 2005
Sorry that was ISerializable.


"Sahil Malik" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> newsE4F518A-34C5-4EDD-A7E5-(E-Mail Removed)...
>> 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

>
>



 
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
Deserializing a class kbodily@charter.net Microsoft VB .NET 1 20th Jan 2007 12:47 AM
Deserializing an inherited class cowznofsky Microsoft VB .NET 2 13th Dec 2006 02:49 AM
deserializing a dataset into a class, is it possible? Greg Merideth Microsoft C# .NET 0 16th Aug 2004 10:26 PM
Deserializing class Jesus Microsoft VC .NET 0 23rd Mar 2004 12:48 AM
DLL not found when deserializing XML class Howard Microsoft Dot NET 0 10th Sep 2003 05:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:39 PM.