XmlSerialize error: There was an error generating the XML document.

We had a very hot problem today, a c# class serialized into XML and threw an exception with the message:

XmlSerialize error: There was an error generating the XML document.

Then we look at the internal cause of the exception, which is a type mismatch problem that turns X into a serialization of Y.

Read More: