{"record":{"id":"7c5b56d216f803f3","repo":"dotnet/wpf","slug":"sr-requiredxmlattributemissing-uri","errorCode":null,"errorMessage":"SR.RequiredXmlAttributeMissing (uri)","messagePattern":"SR\\.RequiredXmlAttributeMissing \\(uri\\)","errorType":"exception","errorClass":"XmlException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureManifest.cs","lineNumber":220,"sourceCode":"        private static Uri ParsePartUri(XmlReader reader, out ContentType contentType)\n        {\n            // should be a relative Package uri with a query portion that contains the ContentType\n            contentType = ContentType.Empty;\n            Uri partUri = null;\n\n            // must be one and only one attribute\n            if (PackagingUtilities.GetNonXmlnsAttributeCount(reader) == 1)\n            {\n                string uriAttrValue = reader.GetAttribute(XTable.Get(XTable.ID.UriAttrName));\n                if (uriAttrValue != null)\n                {\n                    partUri = ParsePartUriAttribute(uriAttrValue, out contentType);\n                }\n            }\n\n            // will be null if we had no success\n            if (partUri == null)\n                throw new XmlException(SR.Format(SR.RequiredXmlAttributeMissing, XTable.Get(XTable.ID.UriAttrName)));\n\n            return partUri;\n        }\n\n        /// <summary>\n        /// Parses a Reference tag\n        /// </summary>\n        /// <param name=\"reader\"></param>\n        /// <returns>partManifestEntry that represents the state of the tag</returns>\n        private static PartManifestEntry ParseReference(XmlReader reader)\n        {\n            Debug.Assert(reader != null);\n\n            // <Reference> found - get part Uri from the tag\n            ContentType contentType = null;\n            Uri partUri = ParsePartUri(reader, out contentType);\n\n            // only allocate if this turns out to be a Relationship transform","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureManifest.cs#L202-L238","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before (hand-crafted signature XML)\n<Reference>\n  <DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>\n</Reference>\n// after\n<Reference Uri=\"/document.xaml\">\n  <DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>\n  <DigestValue>...</DigestValue>\n</Reference>","handlingStrategy":"validation","validationCode":"// Pre-check the Reference XML before Verify\nforeach (var sig in package.GetParts()) { /* locate Signature parts */ }\nvar doc = XDocument.Load(signaturePart.GetStream());\nXNamespace ds = \"http://www.w3.org/2000/09/xmldsig#\";\nbool allHaveUri = doc.Descendants(ds + \"Reference\")\n    .All(r => !string.IsNullOrEmpty((string)r.Attribute(\"Uri\")));\nif (!allHaveUri) throw new InvalidDataException(\"Reference missing Uri attribute\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var status = sigManager.VerifySignatures(true);\n}\ncatch (XmlException ex) when (ex.Message.Contains(\"Uri\"))\n{\n    // treat package as unsigned/corrupt: quarantine and re-sign\n}","preventionTips":["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"],"tags":["wpf","packaging","xml-signature","opc"],"backgroundTag":"missing-required-argument","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}