dotnet/wpf · error · System.Xml.XmlException
SR.RequiredTagNotFound (template: RequiredTagNotFound, arg…
Error message
SR.RequiredTagNotFound (template: RequiredTagNotFound, arg: signatureTimeTag)
What it means
The <SignatureTime> wrapper element itself was not found where the parser required it: ParseSignatureTimeTag throws XmlException with SR.Format(SR.RequiredTagNotFound, signatureTimeTag), i.e. 'Required tag <SignatureTime> not found'. This differs from corruption (5000-5003): the property content is missing the mandatory tag entirely.
Solutions
- Confirm the signature includes a <SignatureTime> SignatureProperty before asking for signing time (check Signature.SignedBy / properties collection)
- Re-sign with PackageDigitalSignatureManager.Sign, which emits the property automatically
- Fall back to parsing the embedded XML signature yourself if a non-WPF tool created it
- Skip signatures lacking the property rather than assuming they are corrupt
Example fix
// guard before reading
dynamic sig = packageSignatures[0];
if (!sig.IsCertificateExists || sig.SignatureProperties == null)
return; // no SignatureTime property present
// then ParseSigningTime Defensive patterns
Strategy: validation
Validate before calling
// Ensure a SignatureTime property exists before asking for the signing time
bool HasSignatureTime(System.IO.Packaging.PackageDigitalSignature sig)
{
foreach (var rel in sig.SignaturePart.GetRelationships()) { /* signature properties present */ }
var xml = new System.Xml.XmlDocument();
xml.Load(sig.SignaturePart.GetStream());
return xml.GetElementsByTagName("SignatureTime").Count > 0;
} Try / catch
try { var t = GetSigningTime(sig); }
catch (XmlException ex) when (ex.Message.Contains("RequiredTagNotFound") || ex.Message.Contains("not found")) {
return (signingTime: (DateTime?)null, trusted: false);
} Prevention
- Sign packages with PackageDigitalSignatureManager, which always emits SignatureTime
- Detect signatures created by external tools and handle missing properties explicitly
- Unit-test signature parsing on packages signed by every tool in your pipeline
When it happens
Trigger: ParseSigningTime -> ParseSignatureTimeTag invoked on a signature whose <SignatureProperty> lacks a <SignatureTime> element — e.g. a signature created without signature properties, or with properties signed under a different Object Id.
Common situations: Reading the signing time of signatures produced by external tools that do not emit the standard SignatureTime property; signatures where the Id/Value references point to the wrong property.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- SR.PackageSignatureCorruption
- SR.UnsupportedHashAlgorithm
- SR.XmlSignatureParseError
- ' ' ID is not a valid XSD ID.
- Cannot remove signature from read-only file.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/4fb1531b22f60edf.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureProperties.cs:315
&& (reader.NodeType == XmlNodeType.EndElement))
{
//We must find a </SignatureProperty> tag at this point,
//else it could be that there are more SignatureTime or
//other tags nested here and that is an error.
if (reader.Read()
&& reader.MoveToContent() == XmlNodeType.EndElement
&& string.Equals(signaturePropertyTag, reader.LocalName, StringComparison.Ordinal))
break;
else
throw new XmlException(SR.PackageSignatureCorruption);
}
else
// if we do not find the nested elements as expected
throw new XmlException(SR.PackageSignatureCorruption);
}
}
else
throw new XmlException(SR.Format(SR.RequiredTagNotFound, signatureTimeTag));
// generate an equivalent DateTime object
if (timeValue != null && timeFormat != null)
return XmlFormattedTimeToDateTime(timeValue, timeFormat);
else
throw new XmlException(SR.PackageSignatureCorruption);
}
/// <summary>
/// DateTime to XML Format
/// </summary>
/// <param name="dt">date time to convert</param>
/// <param name="format">format to use - specified in DateTime syntax</param>
/// <returns>opc-legal string suitable for embedding in XML digital signatures</returns>
private static String DateTimeToXmlFormattedTime(DateTime dt, string format)
{
DateTimeFormatInfo formatter = new DateTimeFormatInfoView on GitHub (pinned to 81131a70a4)