dotnet/wpf · error · XpsPackagingException

ReachPackaging_NotValidSignatureDefinitionElement

Error message

ReachPackaging_NotValidSignatureDefinitionElement

What it means

ReadElement throws this XpsPackagingException when it encounters a child element inside a SignatureDefinition whose name is not one of the allowed elements (SpotLocation, Intent, SignBy, SigningLocale, etc.). The signature definition XML in the package contains an unknown or misplaced element.

Solutions

  1. Only include allowed child elements (SpotLocation, Intent, SignBy, SigningLocale, SignaturePart references) in the SignatureDefinition element
  2. Remove the unexpected element from the XPS markup before reparsing
  3. Catch XpsPackagingException around signature-definition parsing and skip or repair the invalid definition
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XPSSignatureDefinition.cs:560 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/5097ef815cced0f9. Report an issue: GitHub.

Appendix: source

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

            if (reader.Name == XpsS0Markup.SpotLocation)
            {
                ReadAttributes(reader);
            }
            else if (reader.Name == XpsS0Markup.Intent)
            {
                Intent = ReadData(reader);
            }
            else if (reader.Name == XpsS0Markup.SignBy)
            {
                SignBy = DateTime.Parse(ReadData(reader), System.Globalization.CultureInfo.InvariantCulture);
            }
            else if (reader.Name == XpsS0Markup.SigningLocale)
            {
                SigningLocale = ReadData(reader);
            }
            else
            {
                throw new XpsPackagingException(SR.Format(SR.ReachPackaging_NotValidSignatureDefinitionElement, reader.Name));
            }
        }

        private
        string
        ReadData( XmlReader reader )
        {
            string data = null;
            if (!reader.IsEmptyElement)
            {
                bool endLoop = false;
                while (reader.Read() && !endLoop)
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Text:
                            data = reader.Value;
                            endLoop = true;

View on GitHub (pinned to 81131a70a4)