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

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 1726
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*************@TK2MSFTNGP12.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:
XmlSerialization_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 "Programming 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
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...
0
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"....
1
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...
3
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"....
0
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...
1
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
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...
8
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
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.