dotnet/wpf · error · FileFormatException
SR.XpsValidatingLoaderMoreThanOnePrintTicketPart
Error message
SR.XpsValidatingLoaderMoreThanOnePrintTicketPart
What it means
Per the XPS spec, a FixedDocumentSequence, FixedDocument, or FixedPage part may have at most one PrintTicket relationship. XpsS0FixedPageSchema.ValidateRelationships counts relationships of the PrintTicket type on the part and throws FileFormatException as soon as a second one is found.
Solutions
- Remove duplicate PrintTicket relationships so each FDS/FD/FP part has at most one (delete extra rels via part.DeleteRelationship or rebuild the package).
- Keep a single job-level PrintTicket at the FixedDocumentSequence level and remove per-document/per-page duplicates.
- Rebuild the relationship list programmatically before loading: enumerate GetRelationshipsByType and prune to one.
- Re-export the XPS from the original producer after fixing ticket attachment logic.
Example fix
// before
part.CreateRelationship(printTicketUri, TargetMode.Internal, printTicketRelType); // adds a second ticket rel
// after
if (!part.GetRelationshipsByType(printTicketRelType).Any())
part.CreateRelationship(printTicketUri, TargetMode.Internal, printTicketRelType); Defensive patterns
Strategy: validation
Validate before calling
const string printTicketRel = "http://schemas.microsoft.com/xps/2005/06/required-resource:printticket";
var ticketRels = fixedPart.GetRelationshipsByType(printTicketRel).ToList();
if (ticketRels.Count > 1)
ticketRels.Skip(1).ToList().ForEach(r => fixedPart.DeleteRelationship(r.Id)); Type guard
static bool HasSinglePrintTicket(PackagePart part, string relType) =>
part.GetRelationshipsByType(relType).Cast<PackageRelationship>().Take(2).Count() <= 1; Try / catch
try { loader.Load(packageStream); }
catch (FileFormatException ex) { // duplicate PrintTicket rel: open package read-write, prune rels, retry once
PruneDuplicatePrintTicketRels(packageStream); loader.Load(packageStream); } Prevention
- Before adding a PrintTicket relationship, check GetRelationshipsByType for an existing one.
- Prefer one job-level ticket on the FixedDocumentSequence over per-part tickets.
- Never merge packages by blindly copying relationships.
When it happens
Trigger: Opening an XPS package where a FixedDocumentSequence/FixedDocument/FixedPage part has two or more package relationships of type http://schemas.microsoft.com/xps/2005/06/required-resource:PrintTicket (or the printticket rel type); validation enumerates part.GetRelationshipsByType and trips at count>1.
Common situations: Tools merging XPS documents or applying job-level and document-level print tickets by blindly adding relationships; package-editing scripts that append a PrintTicket relationship without removing the existing one; round-tripping through libraries that duplicate relationships.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- SR.XpsValidatingLoaderMoreThanOneDiscardControlInPackage
- SR.XpsValidatingLoaderMoreThanOneThumbnailPart
- SR.XpsValidatingLoaderPrintTicketHasIncorrectType
- PackagePart has more than one Print Ticket relationship.
- PrintTicket was already committed.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/a4cb314e6c3ef9ef.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedSchema.cs:550
}
);
}
public override void ValidateRelationships(Package package, Uri packageUri, Uri partUri, ContentType mimeType)
{
PackagePart part = package.GetPart(partUri);
PackageRelationshipCollection checkRels;
int count;
// Can only have 0 or 1 PrintTicket per FDS, FD or FP part
checkRels = part.GetRelationshipsByType(_printTicketRel);
count = 0;
foreach (PackageRelationship rel in checkRels)
{
count++;
if (count > 1)
{
throw new FileFormatException(SR.XpsValidatingLoaderMoreThanOnePrintTicketPart);
}
// Also check for existence and type
Uri targetUri = PackUriHelper.ResolvePartUri(partUri, rel.TargetUri);
Uri absTargetUri = PackUriHelper.Create(packageUri, targetUri);
PackagePart targetPart = package.GetPart(targetUri);
if (!_printTicketContentType.AreTypeAndSubTypeEqual(new ContentType(targetPart.ContentType)))
{
throw new FileFormatException(SR.XpsValidatingLoaderPrintTicketHasIncorrectType);
}
}
checkRels = part.GetRelationshipsByType(_thumbnailRel);
count = 0;
foreach (PackageRelationship rel in checkRels)
{View on GitHub (pinned to 81131a70a4)