Namespace
System.Xml.Schema
Assembly
System.Xml.dll
Declaration
public sealed class XmlSchemaIntegrityValidationException : XmlSchemaException
Summary
The XmlSchemaIntegrityValidationException class represents an error that occurs when a schema's integrity cannot be validated, such as when required components are missing or the schema fails cryptographic checks.
Properties
| Property | Type | Description |
|---|---|---|
Message | string | The error message that explains the reason for the exception. |
SourceUri | Uri | Gets the URI of the schema that caused the error. |
LineNumber | int | The line number where the error was detected. |
LinePosition | int | The position within the line where the error was detected. |
Constructors
| Signature | Description |
|---|---|
XmlSchemaIntegrityValidationException() | Initializes a new empty instance. |
XmlSchemaIntegrityValidationException(string message) | Initializes with a custom error message. |
XmlSchemaIntegrityValidationException(string message, Exception innerException) | Initializes with a custom message and an inner exception. |
XmlSchemaIntegrityValidationException(string message, Uri sourceUri, int lineNumber, int linePosition) | Initializes with location details. |
Example
using System;
using System.Xml;
using System.Xml.Schema;
class Program
{
static void Main()
{
var schemaSet = new XmlSchemaSet();
try
{
schemaSet.Add(null, "invalidSchema.xsd"); // will trigger integrity error
schemaSet.Compile();
}
catch (XmlSchemaIntegrityValidationException ex)
{
Console.WriteLine($"Integrity error: {ex.Message}");
Console.WriteLine($"Source: {ex.SourceUri}");
Console.WriteLine($"Location: line {ex.LineNumber}, pos {ex.LinePosition}");
}
}
}
Remarks
This exception is thrown only when schema validation is performed with integrity checks enabled (e.g., when using XmlReaderSettings.Schemas with ValidationFlags.ReportValidationWarnings and XmlSchemaObjectTable verification).