dotnet/wpf · error · XpsPackagingException

ReachPackaging_NotSignatureDefinitionElement

Error message

ReachPackaging_NotSignatureDefinitionElement

What it means

ReadXML assumes the caller has already consumed the SignatureDefinition start element; if the reader's current node is not an element or its name is not SignatureDefinition, an XpsPackagingException is thrown. This fires when deserializing an XPS package whose signature-definition XML is misplaced or malformed.

Solutions

  1. Ensure ReadXML is invoked only after the reader has consumed the SignatureDefinition start element
  2. Verify the XML being parsed actually contains a SignatureDefinition element
  3. Advance or position the XmlReader on the SignatureDefinition element before calling ReadXML
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XPSSignatureDefinition.cs:417 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/1ff6712581e5d68a. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XPSSignatureDefinition.cs:417

        /// </summary>
        /// <param name="reader">
        /// The XML Reader used to read the data
        /// </param>
        internal
        void
        ReadXML( XmlReader reader )
        {
            ArgumentNullException.ThrowIfNull(reader);

            //
            // Assume the calling function has already read the
            // SignatureDefinition start element
            //
            if( reader.NodeType != XmlNodeType.Element ||
                reader.Name != XpsS0Markup.SignatureDefinition
              )
            {
                throw new XpsPackagingException(SR.ReachPackaging_NotSignatureDefinitionElement);
            }

            bool exitLoop = false;

            //
            // Read the attributes off of SignatureDefinition
            //
            ReadAttributes( reader );

            while( !exitLoop && reader.Read() )
            {
                switch( reader.NodeType )
                {
                    case XmlNodeType.Element:
                        ReadElement( reader );
                        break;

                    case XmlNodeType.EndElement:

View on GitHub (pinned to 81131a70a4)