dotnet/wpf · error · XpsPackagingException

ReachPackaging_SpotIDRequiredAttribute

Error message

ReachPackaging_SpotIDRequiredAttribute

What it means

Raised from XPSSignatureDefinition.WriteXML when serializing the SignatureDefinition element without a SpotId. Per the XPS specification the SpotID attribute is mandatory on a SignatureDefinition; when SpotId is null the writer cannot emit a valid element and throws XpsPackagingException instead of writing an invalid signature definition.

Solutions

  1. Set the SpotId property on the XPSSignatureDefinition to a valid Guid before serializing with WriteXML
  2. Ensure the SignatureDefinition element in the source XPS markup carries a SpotId attribute
  3. Skip or reject signature definitions that lack a SpotId instead of attempting to write them
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XPSSignatureDefinition.cs:341 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XPSSignatureDefinition.cs:341

        void
        WriteXML(XmlWriter writer)
        {
            ArgumentNullException.ThrowIfNull(writer);

            writer.WriteStartElement(
             XpsS0Markup.SignatureDefinition,
             XpsS0Markup.SignatureDefinitionNamespace
            );

            //Spot ID, Signer Name and xml:lang are attributes of SignatureDefinition
            //Spot ID is required.  If it is not specified, then we throw.
            if (SpotId != null)
            {
                writer.WriteAttributeString(XpsS0Markup.SpotId, XmlConvert.EncodeName(SpotId.ToString()));
            }
            else
            {
                throw new XpsPackagingException(SR.ReachPackaging_SpotIDRequiredAttribute);
            }

            if (RequestedSigner != null)
            {
                writer.WriteAttributeString(XpsS0Markup.RequestedSigner, RequestedSigner);
            }

            if (Culture != null)
            {
                XmlLanguage language = XmlLanguage.GetLanguage(Culture.Name);
                writer.WriteAttributeString(XpsS0Markup.XmlLang, language.ToString());
            }

            //SpotLocation, Intent, Signby, and Signing Location are elements of SignatureDefinition
            if (SpotLocation != null)
            {
                writer.WriteStartElement(XpsS0Markup.SpotLocation);

View on GitHub (pinned to 81131a70a4)