dotnet/wpf · error · System.Xml.XmlException

SR.RequiredTagNotFound (template: RequiredTagNotFound, arg…

Error message

SR.RequiredTagNotFound (template: RequiredTagNotFound, arg: signaturePropertyTag)

What it means

While scanning for the signing-time <SignatureProperty>, ParseSigningTime expects either that element or the closing </SignatureProperties> tag. Any other element name encountered triggers RequiredTagNotFound(signaturePropertyTag) — the signature XML lacks the required structure, so the signature is treated as invalid.

Solutions

  1. Ensure <SignatureProperties> contains only conformant <SignatureProperty> elements
  2. Regenerate the signature with a compliant tool to remove stray elements
  3. Validate the signature part against the OPC/XML-DSig schema before relying on it
  4. Catch XmlException during validation and handle the package as having an invalid signature

Example fix

// before
<SignatureProperties>
  <UnknownElement/> <!-- unexpected -->
</SignatureProperties>
// after
<SignatureProperties>
  <SignatureProperty Id="SignatureTime" Target="#id1">...</SignatureProperty>
</SignatureProperties>
Defensive patterns

Strategy: try-catch

Validate before calling

bool SignaturePropertiesConformant(XElement props) =>
    props.Elements().All(e => e.Name.LocalName == "SignatureProperty");

Try / catch

try { signingTime = ParseSigningTime(stream, signatureId); }
catch (XmlException ex) when (ex.Message.Contains("RequiredTagNotFound")) { /* signature invalid: proceed as unsigned */ }

Prevention

When it happens

Trigger: Signature validation where, inside <SignatureProperties>, the reader hits a LocalName that is neither the expected <SignatureProperty> tag nor the </SignatureProperties> end element — e.g. an unknown nested element.

Common situations: Non-conformant signing tools inserting extra elements into SignatureProperties; hand-edited signature XML; schema drift between signature producer and this validator.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureProperties.cs:193

                        }
                    }
                }
                else
                    //Expected <SignatureProperty> tag not found.
                    //Look for end tag corresponding to </SignatureProperty> or 
                    //if these are other custom defined properties, then anything with
                    //depth greater than 2 should be ignored as these can be nested elements.
                    if (((string.Equals(signaturePropertyTag, reader.LocalName, StringComparison.Ordinal)
                        && (reader.NodeType == XmlNodeType.EndElement)))
                        || reader.Depth > 2)
                        continue;
                    else
                        //If we find the end tag for </SignatureProperties> then we can stop parsing
                        if ((string.Equals(signaturePropertiesTag, reader.LocalName, StringComparison.Ordinal)
                        && (reader.NodeType == XmlNodeType.EndElement)))
                            break;
                        else
                            throw new XmlException(SR.Format(SR.RequiredTagNotFound, signaturePropertyTag));
            }

            //We did find one or more <SignatureProperty> tags but there were none that
            //defined the id attribute and target attribute and <SignatureTime> element tag correctly.
            if(!signatureTimePropertyFound)
                throw new XmlException(SR.PackageSignatureCorruption);

            return signingTime;
        }

       
        //-----------------------------------------------------------------------------
        //
        // Private Methods
        //
        //-----------------------------------------------------------------------------

        /// <summary>

View on GitHub (pinned to 81131a70a4)