473,396 Members | 1,894 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,396 software developers and data experts.

Deserialization versions

Dan
Serialization is great except that it does not accommodate version changes
(adding a property to a class renders it unable to deserialize because an
exception is thrown).

I think I understand the philosophy underlying the choice of the
architecture used by MS in thier decsion to enable version change only by
implementation of ISerializable. However, I want to see the equivalent of
an 'On Error Resume Next' (aka 'go for it') in the deserialization process,
I want to be able to override the BinaryFormatter to hydrate everything it
can without crashing.

It's utterly practical, no? Saves code and bugs introduced in the ugly (my
opinion) ISerializable implementation.

Dan
Nov 15 '05 #1
2 1458
We use a static helper, something like this:

public class Serializer
{
static DataIn(objecttype, info, context)
{
}
static DataOut(object, info, context)
{
}
}

Each class that implements ISerializable simple has 1 line implementations
which call a helper in Serializer.
This way, all our classes are very tolerant of change, far more so than they
were in MFC.

"Programming .NET Components" (Juval Lowy) has quite a good chapter on a
similar concept.

Rob.
"Dan" <mt*******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Serialization is great except that it does not accommodate version changes
(adding a property to a class renders it unable to deserialize because an
exception is thrown).

I think I understand the philosophy underlying the choice of the
architecture used by MS in thier decsion to enable version change only by
implementation of ISerializable. However, I want to see the equivalent of
an 'On Error Resume Next' (aka 'go for it') in the deserialization process, I want to be able to override the BinaryFormatter to hydrate everything it
can without crashing.

It's utterly practical, no? Saves code and bugs introduced in the ugly (my opinion) ISerializable implementation.

Dan

Nov 15 '05 #2
Dan
If I understand you correctly, you are suggesting the DataIn() and DataOut()
methods use reflection to populate the graphs. Something like:

foreach(System.Reflection.PropertyInfo p in
objecttype.GetType().GetProperties)
{
p.SetValue(objecttype, info.GetObject(p.Name));
}

This is a guess, I haven't actually tried it, for example, GetObject must
also be coerced to the correct value type. Am I wrong?


"Robert Hooker" <rh*****@rhooker.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
We use a static helper, something like this:

public class Serializer
{
static DataIn(objecttype, info, context)
{
}
static DataOut(object, info, context)
{
}
}

Each class that implements ISerializable simple has 1 line implementations
which call a helper in Serializer.
This way, all our classes are very tolerant of change, far more so than they were in MFC.

"Programming .NET Components" (Juval Lowy) has quite a good chapter on a
similar concept.

Rob.
"Dan" <mt*******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Serialization is great except that it does not accommodate version changes (adding a property to a class renders it unable to deserialize because an exception is thrown).

I think I understand the philosophy underlying the choice of the
architecture used by MS in thier decsion to enable version change only by implementation of ISerializable. However, I want to see the equivalent of an 'On Error Resume Next' (aka 'go for it') in the deserialization

process,
I want to be able to override the BinaryFormatter to hydrate everything it can without crashing.

It's utterly practical, no? Saves code and bugs introduced in the ugly

(my
opinion) ISerializable implementation.

Dan


Nov 15 '05 #3

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

Similar topics

2
by: Snowman | last post by:
Suppose I have a RootObject which holds a collection of other objects. The other objects have a property (Parent) which refers back to the "parent" collection (b.t.w. my collection is based on...
2
by: Nadav | last post by:
Hi, Introduction: **************** I am trying to DeSerialize a file that was created by an unmanaged application by the binary formatter, to achieve that I am implementing the following...
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
1
by: realgeek | last post by:
Hi. I am writing a class lib that has com interop enabled and it is housed and used within some other application. So then, I serialize one of the classes, and on subsequent launches I try to...
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.