{"record":{"id":"84dd95441431e6c9","repo":"dotnet/wpf","slug":"sr-nothingtosign","errorCode":null,"errorMessage":"SR.NothingToSign","messagePattern":"SR\\.NothingToSign","errorType":"validation","errorClass":"System.ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureManifest.cs","lineNumber":509,"sourceCode":"            {\n                // loop and write - may still be empty\n                foreach (Uri partUri in parts)\n                {\n                    // generate a reference tag\n                    manifest.AppendChild(GeneratePartSigningReference(manager, xDoc, hashAlgorithm, partUri));\n                }\n            }\n\n            // any relationship references?\n            int relationshipCount = 0;\n            if (relationshipSelectors != null)\n            {\n                relationshipCount = GenerateRelationshipSigningReferences(manager, xDoc, hashAlgorithm, relationshipSelectors, manifest);\n            }\n\n            // did we sign anything? Manifest can NOT be empty\n            if (parts == null && relationshipCount == 0)\n                throw new ArgumentException(SR.NothingToSign);\n\n            return manifest;\n        }\n\n        //------------------------------------------------------\n        //\n        //  Private Methods\n        //\n        //------------------------------------------------------\n        /// <summary>\n        /// GenerateRelationshipSigningReferences\n        /// </summary>\n        /// <param name=\"manager\"></param>\n        /// <param name=\"xDoc\"></param>\n        /// <param name=\"hashAlgorithm\"></param>\n        /// <param name=\"relationshipSelectors\"></param>\n        /// <param name=\"manifest\"></param>\n        /// <returns>number of references to be signed</returns>","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureManifest.cs#L491-L527","documentation":"GenerateManifest throws NothingToSign when, after generating references for all specified parts and relationship selectors, no parts were given and zero relationships matched — the resulting <Manifest> would be empty, which XML-DSig forbids. The library refuses to create a signature over nothing.","triggerScenarios":"Calling PackageDigitalSignatureManager.Sign (leading to GenerateManifest) with parts == null and relationshipSelectors that match no relationships in the package (e.g. empty selector list or selectors whose relationship types do not exist).","commonSituations":"Signing a package before any parts/relationships were added; typos in relationship type strings so selectors match nothing; passing null parts while relying on RelationshipSelector filters that evaluate to zero hits.","solutions":["Pass a non-empty parts list to Sign, or ensure relationshipSelectors match at least one relationship","Verify relationship type strings in selectors exactly match those in the package","Check the package actually contains the content you intend to sign before signing","If the package is legitimately empty, don't sign it — guard the call and skip"],"exampleFix":"// before\nmanager.Sign(null, new RelationshipSelector[0]); // nothing matches\n// after\nvar parts = new List<Uri> { PackUriHelper.CreatePartUri(new Uri(\"/doc.xml\", UriKind.Relative)) };\nmanager.Sign(parts, null);","handlingStrategy":"validation","validationCode":"bool HasSomethingToSign(PackageDigitalSignatureManager mgr,\n    IEnumerable<Uri> parts, IEnumerable<RelationshipSelector> selectors)\n{\n    if (parts != null && parts.Any()) return true;\n    if (selectors != null)\n    {\n        var pkgPart = /* iterate package parts */ true;\n        // ensure at least one relationship matches any selector\n        return selectors.Any(s => /* package relationships match s */ true);\n    }\n    return false;\n}","typeGuard":null,"tryCatchPattern":"try { manager.Sign(parts, relationshipSelectors); }\ncatch (ArgumentException ex) when (ex.ParamName == null || ex.Message.Contains(\"sign\")) { /* skip signing empty package */ }","preventionTips":["Only call Sign after package content exists","Verify relationship type strings in selectors match package relationships exactly","Log package part/relationship counts before signing"],"tags":["digital-signature","packaging","empty-input"],"backgroundTag":"empty-required-field","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"}