{"record":{"id":"355f2d9f9ef69ce6","repo":"dotnet/wpf","slug":"specified-object-id-conflicts-with-predefined-package-object","errorCode":null,"errorMessage":"Specified object ID conflicts with predefined Package Object ID.","messagePattern":"Specified object ID conflicts with predefined Package Object ID\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/PackageDigitalSignatureManager.cs","lineNumber":959,"sourceCode":"            IEnumerable<System.Security.Cryptography.Xml.DataObject> signatureObjects,\n            IEnumerable<System.Security.Cryptography.Xml.Reference> objectReferences)\n        {\n            ArgumentNullException.ThrowIfNull(certificate);\n\n            // Check for empty collections in order to provide negative feedback as soon as possible.\n            if (EnumeratorEmptyCheck(parts) && EnumeratorEmptyCheck(relationshipSelectors)\n                && EnumeratorEmptyCheck(signatureObjects) && EnumeratorEmptyCheck(objectReferences))\n                throw new ArgumentException(SR.NothingToSign);\n\n            // check for illegal and/or duplicate id's in signatureObjects\n            if (signatureObjects != null)\n            {\n                List<String> ids = new List<String>();\n                foreach (DataObject obj in signatureObjects)\n                {\n                    // ensure they don't duplicate the reserved one\n                    if (string.Equals(obj.Id, XTable.Get(XTable.ID.OpcAttrValue), StringComparison.Ordinal))\n                        throw new ArgumentException(SR.SignaturePackageObjectTagMustBeUnique, nameof(signatureObjects));\n\n                    // check for duplicates\n                    //if (ids.Contains(obj.Id))\n                    if (ids.Exists(new StringMatchPredicate(obj.Id).Match))\n                        throw new ArgumentException(SR.SignatureObjectIdMustBeUnique, nameof(signatureObjects));\n                    else\n                        ids.Add(obj.Id);\n                }\n            }\n\n            // ensure id is legal Xml id\n            if (!string.IsNullOrEmpty(signatureId))\n            {\n                try\n                {\n                    // An XSD ID is an NCName that is unique.\n                    System.Xml.XmlConvert.VerifyNCName(signatureId);\n                }","sourceCodeStart":941,"sourceCodeEnd":977,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/PackageDigitalSignatureManager.cs#L941-L977","documentation":"VerifySignArguments checks each DataObject's Id against the reserved OPC object identifier ('http://schemas.openxmlformats.org/package/2006/digital-signature/origin'); a match throws ArgumentException (SR.SignaturePackageObjectTagMustBeUnique) for the signatureObjects parameter. The OPC specification reserves that object ID for the package-specific signature object, so user data objects cannot use it.","triggerScenarios":"Calling Sign() with a signatureObjects collection containing a DataObject whose Id equals the reserved OPC object identifier.","commonSituations":"Copy-pasting XML-DSig sample objects that reuse the OPC object Id; programmatically generating DataObjects with the framework's reserved Id string.","solutions":["Rename the DataObject.Id to a custom, non-reserved XML NCName (e.g. 'myObject1').","Remove the conflicting DataObject if it was only meant as boilerplate — the OPC origin object is created by the framework automatically.","Add a pre-sign validation that rejects Ids equal to the reserved OPC identifier."],"exampleFix":"// before\nvar obj = new DataObject { Id = \"http://schemas.openxmlformats.org/package/2006/digital-signature/origin\" };\nmgr.Sign(cert, parts, obj); // ArgumentException\n// after\nvar obj = new DataObject { Id = \"myCustomObject1\" };\nmgr.Sign(cert, parts, obj);","handlingStrategy":"validation","validationCode":"const string OpcReservedId = \"http://schemas.openxmlformats.org/package/2006/digital-signature/origin\";\nif (sigObjects?.Any(o => string.Equals(o.Id, OpcReservedId, StringComparison.Ordinal)) == true)\n    throw new InvalidOperationException(\"DataObject Id collides with reserved OPC object id.\");","typeGuard":null,"tryCatchPattern":"try { mgr.Sign(cert, parts, null, sigObjects, null); }\ncatch (ArgumentException ex) when (ex.ParamName == \"signatureObjects\") { /* rename object ids */ }","preventionTips":["Never reuse the OPC origin object Id in user DataObjects.","Use custom NCName ids like 'obj1' for your objects.","The framework creates the OPC origin object automatically — don't add it yourself."],"tags":["wpf","packaging","argument","reserved-identifier","digital-signature"],"backgroundTag":"invalid-identifier-format","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"}