Occurs when the reader encounters validation errors.
Assembly: System.Xml (in System.Xml.dll)
These events occur while reading an XML instance document if the ValidationType is set to either DTD or Schema. If the ReportValidationWarnings setting has been enabled on the ValidationFlags property these events also occur when any validation warnings are encountered.
If the reader is configured for validation and no validation event handler has been set, an XmlSchemaValidationException is thrown for all validation errors. (Validation warnings do not cause an XmlSchemaValidationException to be thrown).
Validation error messages may expose sensitive content model information. Validation error and warning messages are handled using the ValidationEventHandler delegate, or are exposed as an XmlSchemaValidationException if no event handler is provided to the XmlReaderSettings object (validation warnings do not cause an XmlSchemaValidationException to be thrown). This content model information should not be exposed in untrusted scenarios. Validation warning messages are suppressed by default and can be reported by setting the ReportValidationWarnings flag.
The following example shows the settings to specify to create a reader that validates using an inline schema and that also displays validation warnings. The validation event handler uses the XmlSeverityType enumeration to differentiate between warnings and errors.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.