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

XmlSerializer: Dealing with an evolving class

We have an app that currently uses SOAP for a data file format. It works
well enuogh but I would prefer an XML format that's a little friendlier
to the human eye.

I had started looking at converting over to using the XmlSerializer but
quickly ran into a problem. One thing that is nice about the SOAP
formatter's deserialization is that it can easily deal with different
versions of the data file. The class we're serializing includes a
version field and when deserializing we can examine what version file
we're reading and easily deal with missing or changed fields. For

version = info.GetInt32("Version")
If version = 1 Then
Me.PropertyA = info.GetInt32("OldPropertyName")
End If

If version = 2 Then
Me.PropertyA = info.GetInt32("PropertyA")
End If

In other words, SOAP allows you to do something with fields or properties
that have been removed from the class (for whatever reason) but are still
contained in the old versions of the data. The above example is
simplistic and the real situations get more complicated than that but
hopefully you can get the idea.

Anyway, with XmlSerializer the above isn't possible. In the newer
versions of the software those old properties will simply be ignored when
deserializing the file since they aren't part of the class anymore. I
could leave them in the class but that starts to turn the class into a
mess and they will continue to be serialized.

So, is there a serialization mechanism in .NET that works the same as
SOAP (i.e. all available elements loaded into a dictionary of some sort)
but allows me complete control over the output formatting to make it
easier to read?

Thanks for any advice,
Joel Moore
Jun 21 '06 #1
0 1174

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

Similar topics

by: Zion Zadik | last post by:
Dear all, I have a set of c# data classes which i need to fill their data from xml files. serialization looks to be the best way to accomplish this task. Since the data classes are compiled and...
by: Stuart Robertson | last post by:
I am trying to find a solution that will allow me to use XmlSerializer to serialize/deserialize a collection of objects where a given object is shared between two or more other objects, and not...
by: Chris Aitchison | last post by:
Hello, I am attempting to have a class that I have written serialize so that it can be both passed as a parameter or return value for a webservice, and also be serialized to disk using the...
by: Anthony Bouch | last post by:
Hi I've been reading using the XmlSerializer with custom collections. I've discovered that when serializing a custom collection (a class that implements ICollection, IList etc.) the...
by: Bob Rock | last post by:
Hello, when serializing an array of elements of a class Classname using XmlSerializer.Serialize() I get an XML like the following: <?xml version="1.0"> <ArrayOfClassname> ....... ..........
by: magister | last post by:
Hello I got this working but it is not how I really want it, basically I have an xml file which has a root of <test> and can be filled with 3 different types of <question> elements with different...
by: Steve Long | last post by:
Hello, I hope this is the right group to post this to. I'm trying to serialize a class I've written and I'd like to be able to serialze to both binary and xml formats. Binary serialization is...
by: Wayne | last post by:
I have the following code, this is a form. When I get to the second line I am receiving "Additional information: There was an error reflecting type 'WindowsApplication3.Form1'." Am I just missing...
by: SteveB | last post by:
I'm porting an application from Apache Xerces to .Net and am having a couple of small problems with deserialization. The XML that I'm reading comes from a variety of sources, and there are two...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
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...
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...
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
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...

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.