Ultimately, it depends on the complexity of your model. XmlSerializer
needs a lot of reflection, and the fact that it takes so long to make me suspect that your model is quite complex. For a simple model, you could manually implement deserialization using LINQ-to-XML (pretty easy) or perhaps even XmlReader
(if you feel very brave, it's not easy to get 100% correct).
However, if the model is complex, this is a problem and, frankly, will be very risky in terms of introducing subtle errors.
Another option is the DataContractSerializer
, which processes xml, but not the same as the XmlSerializer
, and, of course, does not have the same control over the layout. I strongly suspect that the DataContractSerializer
will not help you.
There is no direct replacement for the XmlSerializer
that I know of, and if sgen.exe is not an option, I believe that you have options:
- live with him
- rewrite
XmlSerializer
yourself, somehow better than they - use something like LINQ-to-XML and take the effort you make.
Long-term, I would say "conversion formats" and use xml only for obsolete imports. I know some very fast binary protocols that could be easily replaced: p
source share