dotnet/wpf · error · XmlException

SR.UnexpectedXmlTag ( )

Error message

SR.UnexpectedXmlTag ({tag})

What it means

XmlSignatureManifest.ParseManifest throws this XmlException when it encounters an XML tag inside the Signature/Manifest that is not one of the expected tags (Reference, Object, etc.); the message names the unexpected tag. The digital-signature XML deviates from the expected OPC signature manifest structure.

Solutions

  1. Ensure the signature manifest XML only contains expected tags (Manifest, Reference with Relationship/Part forms)
  2. Remove or fix the unexpected '{tag}' element in the SignatureManifest part
  3. Treat the parse failure as an invalid/corrupted signature manifest and reject the package signature
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureManifest.cs:141 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/d28d58690bd74468. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureManifest.cs:141

                {
                    // Parse each reference - distinguish between Relationships and Parts
                    // because we don't store the Relationship-part itself - just it's Relationships.
                    PartManifestEntry partManifestEntry = ParseReference(reader);
                    if (partManifestEntry.IsRelationshipEntry)
                    {
                        foreach (PackageRelationshipSelector relationshipSelector in partManifestEntry.RelationshipSelectors)
                            relationshipManifest.Add(relationshipSelector);
                    }
                    else
                        partManifest.Add(partManifestEntry.Uri);

                    // return the manifest entry to be used for hashing
                    partEntryManifest.Add(partManifestEntry);

                    referenceCount++;
                }
                else
                    throw new XmlException(SR.Format(SR.UnexpectedXmlTag, reader.Name));
            }

            // XmlDSig xsd requires at least one <Reference> tag
            if (referenceCount == 0)
                throw new XmlException(SR.PackageSignatureCorruption);
        }

        /// <summary>
        /// Parse the DigestMethod tag
        /// </summary>
        /// <param name="reader"></param>
        private static string ParseDigestAlgorithmTag(XmlReader reader)
        {
            // verify namespace and lack of attributes
            if (PackagingUtilities.GetNonXmlnsAttributeCount(reader) > 1
                || !string.Equals(reader.NamespaceURI, SignedXml.XmlDsigNamespaceUrl, StringComparison.Ordinal)
                || reader.Depth != 3)
                throw new XmlException(SR.XmlSignatureParseError);

View on GitHub (pinned to 81131a70a4)