Is XML Serializer worth using?

  • Thread starter Thread starter Dave Veeneman
  • Start date Start date
D

Dave Veeneman

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?
 
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.
 
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
 
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/default.asp?url=/library/en-us/dnexxml/html/xml01202003.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
 
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.
 
Back
Top