dotnet/wpf · error · ArgumentException

SR.DigitalSignatureNoFixedDocumentSequence

Error message

SR.DigitalSignatureNoFixedDocumentSequence

What it means

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.

Solutions

  1. Verify the package contains a FixedDocumentSequence (/FixedDocumentSequence.fdseq with correct content type) before constructing DigitalSignatureProvider.
  2. Check XpsDocument.FixedDocumentSequenceReader != null yourself and surface a friendly 'not a valid XPS document' message.
  3. Regenerate the package with a proper XPS writer (XpsDocumentWriter) so the sequence part is emitted.

Example fix

// before
var provider = new DigitalSignatureProvider(package);
// after
using var xps = new XpsDocument(package);
if (xps.FixedDocumentSequenceReader == null)
    throw new InvalidDataException("Package is not a valid XPS document (no FixedDocumentSequence).");
var provider = new DigitalSignatureProvider(package);
Defensive patterns

Strategy: validation

Validate before calling

using var probe = new XpsDocument(package, FileAccess.Read);
bool isXps = probe.FixedDocumentSequenceReader != null;
if (!isXps) throw new InvalidDataException("Package has no FixedDocumentSequence; not a valid XPS document.");

Type guard

bool IsValidXpsPackage(Package p) { try { using var d = new XpsDocument(p, FileAccess.Read); return d.FixedDocumentSequenceReader != null; } catch { return false; } }

Try / catch

try { new DigitalSignatureProvider(package); }
catch (ArgumentException ex) when (ex.Message.Contains("FixedDocumentSequence"))
{ ShowMessage("Digital signatures require a valid XPS document."); }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/c7ecb76e1d5d96a9. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/DigitalSignatureProvider.cs:39

        //
        //  Constructors
        //
        //------------------------------------------------------

        /// <summary>
        /// The constructor
        /// </summary>
        /// <param name="package">The package whose signatures this provider
        /// will manipulate</param>
        public DigitalSignatureProvider(Package package)
        {
            ArgumentNullException.ThrowIfNull(package);

            XpsDocument = new XpsDocument(package);
            FixedDocumentSequence = XpsDocument.FixedDocumentSequenceReader;
            if (FixedDocumentSequence == null)
            {
                throw new ArgumentException(SR.DigitalSignatureNoFixedDocumentSequence);
            }
            // We only want to save the first fixed document since all
            // XPS Viewer signature definitions will be added to the first
            // fixed document.
            FixedDocument =
                FixedDocumentSequence.FixedDocuments[0];

        }
        #endregion Constructors

        #region IDigitalSignatureProvider
        //------------------------------------------------------
        //
        //  IDigitalSignatureProvider
        //
        //------------------------------------------------------

        /// <summary>

View on GitHub (pinned to 81131a70a4)