dotnet/wpf · error · XpsSerializationException

SR.ReachSerialization_NoSerializer

Error message

SR.ReachSerialization_NoSerializer

What it means

Async counterpart of the same invariant: ReachDocumentReferenceSerializerAsync.SerializeDocument (driven by AsyncOperation) throws XpsSerializationException when the resolved FixedDocument has no available serializer. Because this runs on the async serialization operation, the exception surfaces through the async write path and aborts the whole XPS package write.

Solutions

  1. Use standard FixedDocument types or register the custom serializer for the async manager too
  2. Confirm the same graph serializes synchronously, then diff the serializer registrations
  3. Catch XpsSerializationException from the async operation and identify the document type before retrying

Example fix

// before
manager.RegisterSerializer(customDocType, null);
// after
manager.RegisterSerializer(customDocType, new CustomFixedDocumentSerializer());
Defensive patterns

Strategy: try-catch

Validate before calling

bool ok = dr.GetDocument?.Invoke() is System.Windows.Documents.FixedDocument;

Type guard

static bool IsFixedDocument(object o) => o is System.Windows.Documents.FixedDocument;

Try / catch

try { writer.WriteAsync(sequence); } catch (System.Windows.Xps.XpsSerializationException ex) { log.Error("Async serializer missing for document", ex); throw; }

Prevention

When it happens

Trigger: Async XPS save (e.g. XpsDocument.CreateXpsDocumentWriter + WriteAsync) reaching a document whose concrete type has no serializer registered in the manager.

Common situations: WriteAsync on a FixedDocumentSequence with custom document types; mid-migration code where the async path was missed when adding a custom serializer to the sync path only.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachDocumentReferenceSerializerAsync.cs:127

                // Give a parser item a kick
                document.Dispatcher.Invoke(DispatcherPriority.ApplicationIdle,
                    new DispatcherOperationCallback(Idle), null);
            }

            if (document != null)
            {
                ReachSerializer serializer = SerializationManager.GetSerializer(document);

                if(serializer!=null)
                {
                    serializer.SerializeObject(document);
                }
                else
                {
                    //
                    // This shouldn't ever happen.
                    //
                    throw new XpsSerializationException(SR.ReachSerialization_NoSerializer);
                }
            }

        }
    };
}

View on GitHub (pinned to 81131a70a4)