dotnet/wpf · error · XpsPackagingException
ReachPackaging_PrintTicketAlreadyCommitted
Error message
ReachPackaging_PrintTicketAlreadyCommitted
What it means
The PrintTicket setter of XpsFixedDocumentReaderWriter throws XpsPackagingException once the print ticket has already been committed (written) to the package. After Commit, the print ticket part is sealed per the XPS specification and cannot be replaced through this property. This prevents silently producing an inconsistent package.
Solutions
- Set the PrintTicket before calling CommitContent/Commit on the reader/writer.
- Create a new XpsFixedDocumentReaderWriter/package for the changed ticket instead of reusing the committed one.
- Restructure code so all print-ticket configuration is collected first, applied once, then committed.
Example fix
// before fixedDocument.PrintTicket = ticket; fixedDocument.CommitContent(); fixedDocument.PrintTicket = updatedTicket; // throws // after fixedDocument.PrintTicket = updatedTicket; fixedDocument.CommitContent();
Defensive patterns
Strategy: validation
Validate before calling
if (fixedDocument is XpsFixedDocumentReaderWriter fd && fd.PrintTicket != null)
/* ticket already set: verify it has not been committed yet before reassigning */; Try / catch
try { fixedDocument.PrintTicket = ticket; }
catch (XpsPackagingException) { /* ticket committed: create new reader/writer with desired ticket */ } Prevention
- Set PrintTicket before any Commit call.
- Do not reuse committed reader/writer objects.
- Collect user print settings before starting the write pipeline.
When it happens
Trigger: Assigning a non-null PrintTicket to the PrintTicket property of an XpsFixedDocumentReaderWriter after CommitContent has written the ticket to the underlying package part.
Common situations: Long-lived reader/writer objects reused across document writes; code that sets PrintTicket, calls Commit, then later applies user-changed print settings; batch XPS generation loops.
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
- PrintTicket was already committed.
- Current DocumentSequence, FixedDocument, or FixedPage not…
- PackagePart has more than one Print Ticket relationship.
- PrintTicket was already committed.
- Property is not a valid instance of PrintTicket.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/1d100c4af4a41aa9.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsFixedDocumentReaderWriter.cs:312
/// <exception cref="SR.ReachPackaging_PrintTicketAlreadyCommitted">PrintTicket has already been committed.</exception>
/// <exception cref="SR.ReachPackaging_NotAPrintTicket">Property is not a valid PrintTicket instance.</exception>
public PrintTicket PrintTicket
{
get
{
if( _printTicket == null )
{
_printTicket = CurrentXpsManager.EnsurePrintTicket( Uri );
}
return _printTicket;
}
set
{
if(value != null)
{
if (_isPrintTicketCommitted)
{
throw new XpsPackagingException(SR.ReachPackaging_PrintTicketAlreadyCommitted);
}
if (!value.GetType().Equals(typeof(PrintTicket)))
{
throw new XpsPackagingException(SR.ReachPackaging_NotAPrintTicket);
}
_printTicket = value.Clone();
}
else
{
_printTicket = null;
}
}
}
/// <summary>
/// Gets a collection of all fixed pages that are contained within
/// this fixed document.View on GitHub (pinned to 81131a70a4)