473,586 Members | 2,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is XML Serializer worth using?

Is XML Serialization worth using to persist classes to file? I've been
trying for a day to get it to work on some fairly simple classes. what I'm
getting back are error messages like "There is an error in XML document (35,
30)." That's not very helpful!

The XML Serializer class is beginning to look like another bogus Microsoft
technology. Should I abandon it now, or am I simply letting my frustration
get the better of me?
Nov 16 '05 #1
6 1737
So what's at (35,30)?
If you can post a small example of the problem (the smaller the better)
there are several people that hang out here that use the XML serializer. My
experience is that it's very useful, but I use it on a daily basis so
perhaps I've just grown numb ;)

Keep in mind that there are types that can't be serialized with the XML
serializer, and it only works on public fields and properties.

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com/blogs/mickey

"Dave Veeneman" <da****@nospam. com> wrote in message
news:e2******** *****@TK2MSFTNG P12.phx.gbl...
Is XML Serialization worth using to persist classes to file? I've been
trying for a day to get it to work on some fairly simple classes. what I'm
getting back are error messages like "There is an error in XML document (35, 30)." That's not very helpful!

The XML Serializer class is beginning to look like another bogus Microsoft
technology. Should I abandon it now, or am I simply letting my frustration
get the better of me?

Nov 16 '05 #2
I'll take that as a "Maybe you're letting your frustration get the better of
you." I mainly wanted to make sure I wasn't headed down some blind alley.
The fact that there really are people using it on a daily basis gives me
enough confidence to slog on. Once I master this, I think it really will
make life easier.
So what's at (35,30)?
How would I interpret the coordinates in the error message? I'm not sure
what (35, 30) refers to. Line/column position?
Keep in mind that there are types that can't be serialized with the XML
serializer, and it only works on public fields and properties.


I've worked out the former problem-- I think. I have created public
properties for the member variables I need to persist. I've prefixed those
property names to set them apart from 'normal' properties, like this:
XmlSerializatio n_FooProperty. Good idea? Bad idea? Better way to go about
it?

Also, I'm having trouble finding documentation on the types that the XML
serializer will and won't serialize. Can you suggest a good source?

Thanks much for your help.

Dave Veeneman
Foresight Systems
Nov 16 '05 #3
Dave,
So what's at (35,30)?


How would I interpret the coordinates in the error message? I'm
not sure what (35, 30) refers to. Line/column position?


Exactly. Line 35, column 30.

There's a whole section in the documentation on how to serialize
objects. Look under "Programmin g with the .NET Framework/Serializing
Objects".

Also see this article in MSDN (first of a three part series):

http://msdn.microsoft.com/msdnmag/is...04/net/toc.asp

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 16 '05 #4
Thanks, Chris. I also found another good article, this one with a FAQ
section that talks about limitations of XML Serialization:

http://msdn.microsoft.com/library/de...ml01202003.asp

I think my biggest problem is that XML Serialization won't serialize
hastables, and I use a couple of them in my object hierarchy. I think I may
look at SOAP serialization as an alternative-- I understand it has fewer
limitations.

Dave Veeneman
Foresight Systems
Nov 16 '05 #5
> The XML Serializer class is beginning to look like another bogus Microsoft
technology. Should I abandon it now, or am I simply letting my frustration
get the better of me?


The MSDN Magazine series that Chris Timmons recommended looks like a good
primer on serialization. Here's a link to the article:

http://msdn.microsoft.com/library/de...04/net/toc.asp

I think my frustration *was* getting the better of me...

Dave Veeneman
Foresight Systems
Nov 16 '05 #6
The Richter article shows how to deserialize a Version 1 object to a Version
2 object (or even how to deserialize a foo object to a bar object). Well
worth reading.
Nov 16 '05 #7

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

Similar topics

1
1257
by: | last post by:
Hi, When we get generic collections will the serializer change so we dont need to give it a type parameter for collections ? Currently today if we serialize an ArrayList, we have to give it a Type array. If the collection is of a specific type, is this still needed? Thanks.
0
1478
by: Mark | last post by:
Hi all, i'm trying to serialize a class. Using the constructor of XmlSerializer i get these (odd?) errors: "File or assembly name goseij9w.dll, or one of its dependencies, was not found". Everytime i run the testprogram it complains about another exotically named dll like et_kn-hl.dll or afeaqisr.dll. Even the example from msdn throws...
1
1331
by: James | last post by:
Hi, I have an array of structures I would like to turn into an XML string using the XML serializer. The problem I am running into is that I get an exception. Depending on what data type I set the serializer up with (my structure or ArrayList), I get either "Invalid Cast" or "...did not expect type <my structure> ..." Does anybody know...
3
2105
by: Mark | last post by:
Hi all, i'm trying to serialize a class. Using the constructor of XmlSerializer i get these (odd?) errors: "File or assembly name goseij9w.dll, or one of its dependencies, was not found". Everytime i run the testprogram it complains about another exotically named dll like et_kn-hl.dll or afeaqisr.dll. Even the example from msdn throws...
0
983
by: Albert Jan | last post by:
Hi, I use the XmlSerializer in C# to serialize an object containing an email message to xml. This works often fine, but for some mailmessages the serialization fails with the message 'There was an error generating the XML document' Can the serialization process be dependent on the data in the object members? If so, what kind of data can...
1
1615
by: Michael A. Covington | last post by:
Is there an easy way to insert an encryption routine in between the XML serializer and the file it is writing or reading?
6
4655
by: Wilfried Mestdagh | last post by:
Hi, I use this class to save application settings in a xml file. Sometime I have exception error in the Load method, and sometime in the Save method. Is this a bug in NET or is there something I do wrong ? I load in the form Load and save in the FormClosing. This is the class: public class Config { public formSettings MainForm = new...
8
4273
by: Q. John Chen | last post by:
I have following code: public class Member { public string FirstName; public string LastName; public string GetXml() { StringBuilder sb = new StringBuilder(); XmlSerializer serializer
1
1666
by: hawkeye.parker | last post by:
using .net 1.1 i think i might want to replace the xml serializer which my .Net webservice uses with a custom serializer. anyone know: a) is this possible? b) if so, is it terribly difficult (to create a proper webservice compliant serializer and override the .net "default" webservice xml serializer)?
0
7915
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8204
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7965
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6617
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3838
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.