Jumping on the XML Serialization Band Wagon
Recently both David Hayden and Brendan Tompkins discussed some XML Serialization stuff.
David talked a bit about what XML Serialization is and gave some examples. Brendan then showed a helper class that he'd written a while ago.
Rather than leave comments on both of their posts, I thought I'd stand bold and proud and hold my head up high, and make a fool of myself in public by responding with a post of my own.
XML Serialization is something that's caused me many hours of grief, for many different reasons, but mostly it's an extremely cool way of persisting and restoring data. Most of my dealings with it have been in web services - the web services I write here at work need to pass complex types, and so it's a lot easier to do the de/serialization yourself.
I've talked a bit about it in past on my blog, but I thought I'd give a quick summary of things I've dealt with and give some links into my old posts, especially since you all want to read my blog all day, right?
When you try to serialize any collection classes (Collection, Hashtable, etc - and also any that you write that inherit from CollectionBase or implement things like IEnumerable) you're in for some very interesting times. I did a post on how I got around it here.
I then went on to complain that it was still very annoying that I had to do all the serialization myself just to get the the objects through a web service, but I found the answer I was looking for in the IXMLSerialible interface (and I did get confirmation that if you need it before .net 2.0, it's ok to use it, jsut be careful :)
The biggest issue I've come across with the XMLSerializer is the performance. I wrote about how invoking it manually in a web service caused major scalability problems, and what I did to solve it.
Finally, I wrote this post talking a little about reflection. Down the bottom of the page I mentioned that I had discovered a tool called sgen.exe which ships with VS2005, which pregenerates all the custom code normally generated during the constructor call to the XMLSerializaer.
So, that's a summary of what I've mentioned so far about serialization - since I've moved to CodeBetter and we don't have search for individual blogs anymore, I thought some people who are interested in searialization (and haven't already read them) might find them of use.
Brendan, David, my whole point of writing this was to remind you both to be careful when you use the serializer a lot, because the constructor will max out your CPU :)
Listening to: rip it up - 28 days - (3:28)