XmlSerializer Performance Issue when Specifying XmlRootAttribute
- by Dougc
I'm currently having a really weird issue and I can't seem to figure out how to resolve it.
I've got a fairly complex type which I'm trying to serialize using the XmlSerializer class. This actually functions fine and the type serializes properly, but seems to take a very long time in doing so; around 5 seconds depending on the data in the object.
After a bit of profiling I've narrowed the issue down - bizarrely - to specifying an XmlRootAttribute when calling XmlSerializer.Serialize. I do this to change the name of a collection being serialized from ArrayOf to something a bit more meaningful. Once I remove the parameter the operation is almost instant!
Any thoughts or suggestions would be excellent as I'm entirely stumped on this one!