Why does XmlSerializer throws an Exception and raise a ValidationEvent when a schema validation error occurs inside IXmlSerializable.ReadXml()
问题 I have written some tests for reading an XML file and validating it against an XSD schema. My data objects are using a mix of attribute based and custom IXmlSerializable implementation and I am using the XmlSerializer to perform deserialization. My test involves inserting an unknown element into the XML so that it does not conform to the schema. I then test if the validation event fires. If the unknown element is placed in the XML so it's a child of one of the attribute based data classes (i