dotnet/wpf · error · XpsSerializationException
SR.ReachSerialization_NoFixedPages
Error message
SR.ReachSerialization_NoFixedPages
What it means
RegisterDocumentEnd validates that the FixedDocument being closed actually contains at least one page. An XPS FixedDocument with zero FixedPages is invalid, so when _pageNumber <= 0 the manager throws XpsSerializationException(SR.ReachSerialization_NoFixedPages) instead of emitting an empty document.
Solutions
- Ensure at least one page is serialized (RegisterPageStart/RegisterPageEnd) before RegisterDocumentEnd.
- If content can legitimately be empty, emit a blank placeholder FixedPage rather than closing an empty document.
- Fix the paginator so its page count matches the pages actually serialized.
- On serialization failure, abort the whole document/sequence instead of calling RegisterDocumentEnd on a partial document.
Example fix
// before manager.RegisterDocumentStart(); // no pages added manager.RegisterDocumentEnd(); // throws // after manager.RegisterDocumentStart(); manager.RegisterPageStart(); // ... write blank/content page ... manager.RegisterPageEnd(); manager.RegisterDocumentEnd();
Defensive patterns
Strategy: validation
Validate before calling
if (pagesInCurrentDocument == 0)
{
// emit a blank page or abort instead of ending an empty document
SerializeBlankPage(manager);
} Try / catch
try
{
manager.RegisterDocumentEnd();
}
catch (System.Windows.Xps.XpsSerializationException ex) when (ex.Message.Contains("page"))
{
// document had no pages: emit a placeholder page or abort the document
SerializeBlankPage(manager);
manager.RegisterDocumentEnd();
} Prevention
- Check the page count from your paginator before starting a document.
- Always emit at least one FixedPage per FixedDocument, even for empty content.
- On mid-document failure, abort the whole package instead of calling RegisterDocumentEnd.
When it happens
Trigger: Calling RegisterDocumentEnd without any RegisterPageStart/RegisterPageEnd pair in between — e.g. a paginator reports zero pages for a document, or page serialization was skipped/aborted.
Common situations: Printing empty collections or a DocumentPaginator whose GetPage count is 0; exceptions during the first page leaving the document empty; filtering logic that skips all pages but still closes the document.
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_NoFixedDocuments
- 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/591d07a0a464c34f.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsSerializationManager.cs:871
_documentNumber += 1;
//
// Clearing the number of pages for this document
//
_pageNumber = 0;
}
internal
void
RegisterDocumentEnd()
{
//
// It is invalid to have a document with no fixed pages
// If no fixed pages have been searialzed throw
//
if( _pageNumber <= 0 )
{
throw new XpsSerializationException(SR.ReachSerialization_NoFixedPages);
}
//
// Exiting Document Started state
//
_documentStartState = false;
}
void
IXpsSerializationManager.RegisterPageStart()
{
if( _pageStartState )
{
throw new XpsSerializationException(SR.ReachSerialization_FixedPageInPage);
}
//
// Entering Page Started state
//
_pageStartState = true;View on GitHub (pinned to 81131a70a4)