System.XmlSchemaIntegrityValidationException

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

PropertyTypeDescription
MessagestringThe error message that explains the reason for the exception.
SourceUriUriGets the URI of the schema that caused the error.
LineNumberintThe line number where the error was detected.
LinePositionintThe position within the line where the error was detected.

Constructors

SignatureDescription
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).

Related Topics