dotnet/wpf · error · XmlException
SR.RequiredXmlAttributeMissing (uri)
Error message
SR.RequiredXmlAttributeMissing (uri)
What it means
ParsePartUri failed to extract a valid part URI from the signature manifest, so the required URI attribute (per the OPC/XMLDSig manifest schema) is missing. The library throws because every Reference entry in a package signature must carry a Uri attribute identifying the signed part; without it the manifest is structurally invalid and cannot be verified.
Solutions
- Inspect the signature XML part (/_rels/.rels signature part) and ensure each <Reference> has a non-empty Uri attribute
- Re-sign the package with PackageDigitalSignatureManager.Sign instead of external tools
- Validate the signature XML against the OPC digital signature schema before Verify
- Check that the signing tool writes OPC-compliant manifests (WPF/XPS compatible)
Example fix
// before (hand-crafted signature XML) <Reference> <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> </Reference> // after <Reference Uri="/document.xaml"> <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> <DigestValue>...</DigestValue> </Reference>
Defensive patterns
Strategy: validation
Validate before calling
// Pre-check the Reference XML before Verify
foreach (var sig in package.GetParts()) { /* locate Signature parts */ }
var doc = XDocument.Load(signaturePart.GetStream());
XNamespace ds = "http://www.w3.org/2000/09/xmldsig#";
bool allHaveUri = doc.Descendants(ds + "Reference")
.All(r => !string.IsNullOrEmpty((string)r.Attribute("Uri")));
if (!allHaveUri) throw new InvalidDataException("Reference missing Uri attribute"); Try / catch
try
{
var status = sigManager.VerifySignatures(true);
}
catch (XmlException ex) when (ex.Message.Contains("Uri"))
{
// treat package as unsigned/corrupt: quarantine and re-sign
} Prevention
- Always sign with PackageDigitalSignatureManager rather than external XMLDSig tools
- Never hand-edit signature parts; regenerate signatures instead
- Validate signature XML against the OPC schema in CI for signed artifacts
- Reject packages whose signature parts fail a schema pre-check at ingest
When it happens
Trigger: Calling PackageDigitalSignatureManager.Verify (or opening a signed package) where a <Reference> element in the Signature part lacks the Uri attribute, or has an empty/malformed Uri value that fails part-URI parsing.
Common situations: Signature files hand-edited or regenerated by third-party signing tools that do not emit the Uri attribute; truncated/corrupted signature XML after partial file transfer; non-OPC signing tools writing plain XMLDSig without OPC's required attributes.
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.MultipleRelationshipTransformsFound
- SR.RelationshipTransformNotFollowedByCanonicalizationTransfo…
- SR.XmlSignatureParseError
- SR.PackageSignatureObjectTagRequired
- SR.PackageSpecificReferenceTagMustBeUnique
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/7c5b56d216f803f3.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureManifest.cs:220
private static Uri ParsePartUri(XmlReader reader, out ContentType contentType)
{
// should be a relative Package uri with a query portion that contains the ContentType
contentType = ContentType.Empty;
Uri partUri = null;
// must be one and only one attribute
if (PackagingUtilities.GetNonXmlnsAttributeCount(reader) == 1)
{
string uriAttrValue = reader.GetAttribute(XTable.Get(XTable.ID.UriAttrName));
if (uriAttrValue != null)
{
partUri = ParsePartUriAttribute(uriAttrValue, out contentType);
}
}
// will be null if we had no success
if (partUri == null)
throw new XmlException(SR.Format(SR.RequiredXmlAttributeMissing, XTable.Get(XTable.ID.UriAttrName)));
return partUri;
}
/// <summary>
/// Parses a Reference tag
/// </summary>
/// <param name="reader"></param>
/// <returns>partManifestEntry that represents the state of the tag</returns>
private static PartManifestEntry ParseReference(XmlReader reader)
{
Debug.Assert(reader != null);
// <Reference> found - get part Uri from the tag
ContentType contentType = null;
Uri partUri = ParsePartUri(reader, out contentType);
// only allocate if this turns out to be a Relationship transformView on GitHub (pinned to 81131a70a4)