dotnet/wpf · error · XpsSerializationException
SR.ReachSerialization_NoFixedDocuments
Error message
SR.ReachSerialization_NoFixedDocuments
What it means
RegisterDocumentSequenceEnd validates that the FixedDocumentSequence being closed contained at least one FixedDocument. When no document was serialized (_pageNumber/document counter <= 0), it throws XpsSerializationException(SR.ReachSerialization_NoFixedDocuments), since an XPS package with an empty document sequence is invalid.
Solutions
- Ensure at least one FixedDocument is fully serialized before ending the document sequence.
- Check the input for emptiness before starting serialization and surface a friendly 'nothing to print' error instead of producing an invalid package.
- On early abort, discard the package/stream rather than calling the sequence-end registration.
- Fix the paginator/serialization driver so its document count matches what is actually emitted.
Example fix
// before manager.RegisterDocumentSequenceStart(); // no documents added manager.RegisterDocumentSequenceEnd(); // throws // after manager.RegisterDocumentSequenceStart(); manager.RegisterDocumentStart(); manager.RegisterPageStart(); // ... content ... manager.RegisterPageEnd(); manager.RegisterDocumentEnd(); manager.RegisterDocumentSequenceEnd();
Defensive patterns
Strategy: validation
Validate before calling
if (documentsInSequence == 0)
{
// nothing to serialize: abort the package instead of ending an empty sequence
AbortSerialization("No FixedDocuments were produced; nothing to print.");
return;
} Try / catch
try
{
manager.RegisterDocumentSequenceEnd();
}
catch (System.Windows.Xps.XpsSerializationException ex) when (ex.Message.Contains("document"))
{
// empty sequence: discard the package and report 'nothing to print'
DiscardCurrentPackage();
} Prevention
- Check that at least one FixedDocument was written before ending the sequence.
- Validate input content (non-empty visual tree / paginator) before starting serialization.
- On early failure, abandon the package entirely rather than closing it as a valid sequence.
When it happens
Trigger: Calling RegisterDocumentSequenceEnd (and the manager's end-of-serialization path) without any RegisterDocumentStart/RegisterDocumentEnd pair — e.g. a paginator returns zero documents, or all documents were skipped/aborted before the sequence is closed.
Common situations: Printing jobs with nothing to print (empty visual trees, filtered-out content); failure on the very first FixedDocument aborting serialization while cleanup still ends the sequence; batch print tools generating zero output.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- SR.ReachSerialization_NoFixedPages
- SR.ReachSerialization_FixedDocumentInDocument
- SR.ReachSerialization_FixedDocumentInDocument
- SR.ReachSerialization_FixedDocumentInPage
- SR.ReachSerialization_FixedDocumentInPage
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/f83f1882aacb727b.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsSerializationManager.cs:924
internal
void
RegisterDocumentSequenceStart()
{
_documentNumber = 0;
}
internal
void
RegisterDocumentSequenceEnd()
{
//
// It is invalid to have a document sequence with no fixed documents
// If no fixed documents have been searialzed throw
//
if( _pageNumber <= 0 )
{
throw new XpsSerializationException(SR.ReachSerialization_NoFixedDocuments);
}
}
internal
override
BasePackagingPolicy
PackagingPolicy
{
get
{
return _packagingPolicy;
}
}
internal
override
XpsResourcePolicyView on GitHub (pinned to 81131a70a4)