{"record":{"id":"c7ecb76e1d5d96a9","repo":"dotnet/wpf","slug":"sr-digitalsignaturenofixeddocumentsequence","errorCode":null,"errorMessage":"SR.DigitalSignatureNoFixedDocumentSequence","messagePattern":"SR\\.DigitalSignatureNoFixedDocumentSequence","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DigitalSignatureProvider.cs","lineNumber":39,"sourceCode":"        //\n        //  Constructors\n        //\n        //------------------------------------------------------\n\n        /// <summary>\n        /// The constructor\n        /// </summary>\n        /// <param name=\"package\">The package whose signatures this provider\n        /// will manipulate</param>\n        public DigitalSignatureProvider(Package package)\n        {\n            ArgumentNullException.ThrowIfNull(package);\n\n            XpsDocument = new XpsDocument(package);\n            FixedDocumentSequence = XpsDocument.FixedDocumentSequenceReader;\n            if (FixedDocumentSequence == null)\n            {\n                throw new ArgumentException(SR.DigitalSignatureNoFixedDocumentSequence);\n            }\n            // We only want to save the first fixed document since all\n            // XPS Viewer signature definitions will be added to the first\n            // fixed document.\n            FixedDocument =\n                FixedDocumentSequence.FixedDocuments[0];\n\n        }\n        #endregion Constructors\n\n        #region IDigitalSignatureProvider\n        //------------------------------------------------------\n        //\n        //  IDigitalSignatureProvider\n        //\n        //------------------------------------------------------\n\n        /// <summary>","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DigitalSignatureProvider.cs#L21-L57","documentation":"The DigitalSignatureProvider constructor wraps the given package in an XpsDocument and requires a FixedDocumentSequence reader; if the package contains no FixedDocumentSequence (XpsDocument.FixedDocumentSequenceReader == null) it throws ArgumentException(SR.DigitalSignatureNoFixedDocumentSequence). Only XPS packages with a document sequence can be signature-managed.","triggerScenarios":"new DigitalSignatureProvider(package) where the Package is not a valid XPS package — no FixedDocumentSequence part (e.g. an OLE, plain OPC, or mis-built package).","commonSituations":"Passing a non-XPS OPC package, a truncated/incomplete .xps file, or a package created without adding a FixedDocumentSequence before attempting digital signature operations in the XPS viewer/RM pipeline.","solutions":["Verify the package contains a FixedDocumentSequence (/FixedDocumentSequence.fdseq with correct content type) before constructing DigitalSignatureProvider.","Check XpsDocument.FixedDocumentSequenceReader != null yourself and surface a friendly 'not a valid XPS document' message.","Regenerate the package with a proper XPS writer (XpsDocumentWriter) so the sequence part is emitted."],"exampleFix":"// before\nvar provider = new DigitalSignatureProvider(package);\n// after\nusing var xps = new XpsDocument(package);\nif (xps.FixedDocumentSequenceReader == null)\n    throw new InvalidDataException(\"Package is not a valid XPS document (no FixedDocumentSequence).\");\nvar provider = new DigitalSignatureProvider(package);","handlingStrategy":"validation","validationCode":"using var probe = new XpsDocument(package, FileAccess.Read);\nbool isXps = probe.FixedDocumentSequenceReader != null;\nif (!isXps) throw new InvalidDataException(\"Package has no FixedDocumentSequence; not a valid XPS document.\");","typeGuard":"bool IsValidXpsPackage(Package p) { try { using var d = new XpsDocument(p, FileAccess.Read); return d.FixedDocumentSequenceReader != null; } catch { return false; } }","tryCatchPattern":"try { new DigitalSignatureProvider(package); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"FixedDocumentSequence\"))\n{ ShowMessage(\"Digital signatures require a valid XPS document.\"); }","preventionTips":["Validate package structure before signature operations.","Generate packages with XpsDocumentWriter.","Warn users early when a file is not real XPS."],"tags":["wpf","xps","digital-signature","argument"],"backgroundTag":"invalid-argument-value","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"}