{"record":{"id":"07a4530f95083129","repo":"dotnet/wpf","slug":"sr-signatureoriginnotfound","errorCode":null,"errorMessage":"SR.SignatureOriginNotFound","messagePattern":"SR\\.SignatureOriginNotFound","errorType":"exception","errorClass":"FileFormatException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/PackageDigitalSignatureManager.cs","lineNumber":1282,"sourceCode":"            // only search once\n            if (!_originSearchConducted)\n            {\n                try\n                {\n                    Debug.Assert(!_originPartExists, \"Logic Error: If OriginPartExists, OriginSearchConducted should be true.\");\n                    PackageRelationshipCollection containerRelationships = _container.GetRelationshipsByType(_originRelationshipType);\n                    foreach (PackageRelationship r in containerRelationships)\n                    {\n                        // don't resolve if external\n                        if (r.TargetMode != TargetMode.Internal)\n                            throw new FileFormatException(SR.PackageSignatureCorruption);\n\n                        // resolve target (may be relative)\n                        Uri targetUri = PackUriHelper.ResolvePartUri(r.SourceUri, r.TargetUri);\n\n                        // if part does not exist - we throw\n                        if (!_container.PartExists(targetUri))\n                            throw new FileFormatException(SR.SignatureOriginNotFound);\n\n                        PackagePart p = _container.GetPart(targetUri);\n\n                        // inspect content type - ignore things we don't understand\n                        if (p.ValidatedContentType().AreTypeAndSubTypeEqual(_originPartContentType))\n                        {\n                            // throw if more than one relationship to an origin part that we recognize\n                            if (_originPartExists)\n                                throw new FileFormatException(SR.MultipleSignatureOrigins);\n\n                            // overwrite default if some container is using some other name\n                            _originPartName = targetUri;\n                            _originPart = p;\n                            _originPartExists = true;\n                        }\n                    }\n                }\n                finally","sourceCodeStart":1264,"sourceCodeEnd":1300,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/PackageDigitalSignatureManager.cs#L1264-L1300","documentation":"While locating the Digital Signature Origin part at construction, the manager resolves each internal signature-origin relationship and throws FileFormatException(SR.SignatureOriginNotFound) when the resolved target part does not exist in the package. The package claims a signature origin via a relationship but the actual origin part is missing.","triggerScenarios":"Constructing PackageDigitalSignatureManager on a package whose root relationship of type http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin points to a part that is absent (deleted or not copied).","commonSituations":"Signature origin part stripped during repackaging or signing removal done incorrectly; zip tooling that dropped the part; partial file transfer truncation.","solutions":["Add back the missing signature origin part at the path the relationship targets","Remove the dangling signature-origin relationship from the root .rels, then re-sign with Sign","Rebuild/re-sign the package from a known-good copy","If signatures are irrelevant to your workflow, catch FileFormatException and proceed without signature support"],"exampleFix":"// before: dangling relationship in _rels/.rels\n// after: remove the relationship, then\nusing var pkg = Package.Open(path, FileMode.Open, FileAccess.ReadWrite);\nvar signer = new PackageDigitalSignatureManager(pkg) { Certificate = cert };\nsigner.Sign(new Uri(\"/metadata/sig-origin.xml\", UriKind.Relative));","handlingStrategy":"try-catch","validationCode":"bool originPartExists = pkg.GetRelationshipsByType(\n    \"http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin\")\n    .Where(r => r.TargetMode == TargetMode.Internal)\n    .Any(r => pkg.PartExists(PackUriHelper.ResolvePartUri(\"/\", r.TargetUri)));","typeGuard":null,"tryCatchPattern":"try { var signer = new PackageDigitalSignatureManager(pkg); }\ncatch (FileFormatException)\n{ /* no usable origin; treat as unsigned or re-sign */ }","preventionTips":["Use RemoveAllSignatures rather than deleting parts directly","Copy packages with OPC-aware tools that keep all parts","Check that every root relationship target exists before signature work"],"tags":["opc","signature-origin","missing-part","corrupt-package"],"backgroundTag":"entity-not-found","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"}