dotnet/wpf · error · FileFormatException
SR.XpsValidatingLoaderPrintTicketHasIncorrectType
Error message
SR.XpsValidatingLoaderPrintTicketHasIncorrectType
What it means
The target part of a PrintTicket relationship must have Content Type application/vnd.ms-printing.printticket+xml. When ValidateRelationships resolves the relationship target and its type/subtype doesn't match, it throws FileFormatException because the referenced part is not a real PrintTicket.
Solutions
- Ensure the PrintTicket relationship target part has Content Type application/vnd.ms-printing.printticket+xml (fix [Content_Types].xml or override entry).
- Point the relationship at the actual PrintTicket part instead of the wrong target.
- Replace the target with a genuine PrintTicket (serialize a PrintTicket/PrintQueue ticket to a properly typed part).
- Validate all printticket rels with a quick pass over GetRelationshipsByType before loading.
Example fix
// before PackagePart ticket = pkg.CreatePart(ticketUri, "application/xml"); // after PackagePart ticket = pkg.CreatePart(ticketUri, "application/vnd.ms-printing.printticket+xml");
Defensive patterns
Strategy: validation
Validate before calling
const string printTicketType = "application/vnd.ms-printing.printticket+xml";
foreach (var rel in fixedPart.GetRelationshipsByType(printTicketRel)) {
var target = package.GetPart(PackUriHelper.ResolvePartUri(fixedPart.Uri, rel.TargetUri));
if (!target.ContentType.Equals(printTicketType, StringComparison.OrdinalIgnoreCase))
throw new InvalidDataException($"PrintTicket rel target {target.Uri} has wrong type {target.ContentType}");
} Type guard
static bool IsPrintTicketPart(PackagePart p) =>
p.ContentType.Equals("application/vnd.ms-printing.printticket+xml", StringComparison.OrdinalIgnoreCase); Try / catch
try { loader.Load(packageStream); }
catch (FileFormatException ex) { // wrong ticket target type: fix [Content_Types].xml or retarget rel, then retry
FixPrintTicketContentTypes(packageStream); loader.Load(packageStream); } Prevention
- Create PrintTicket parts with the exact vnd.ms-printing.printticket+xml content type.
- Add a PrintTicket MIME default/override in [Content_Types].xml.
- After retargeting relationships, re-verify target part types.
When it happens
Trigger: Loading an XPS package where a PrintTicket relationship points to a part whose Content Type is not application/vnd.ms-printing.printticket+xml (e.g. points to an XML settings file, an image, or a part with a typo'd MIME type in [Content_Types].xml).
Common situations: Relationship targets edited or re-pointed by tooling without updating the part's declared Content Type; a generic .xml part used as a ticket with default application/xml content type; package repair tools that preserve relationships but re-create parts with wrong types.
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.XpsValidatingLoaderMoreThanOnePrintTicketPart
- SR.XpsValidatingLoaderRestrictedFontHasIncorrectType
- ' ' ContentType is not valid.
- PackagePart has more than one Print Ticket relationship.
- PackagePart URI does not correspond to a FixedDocument.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/ca5f23b0a511bd8b.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedSchema.cs:561
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)
{
count++;
if (count > 1)
{
throw new FileFormatException(SR.XpsValidatingLoaderMoreThanOneThumbnailPart);
}
// Also check for existence and type
Uri targetUri = PackUriHelper.ResolvePartUri(partUri, rel.TargetUri);
Uri absTargetUri = PackUriHelper.Create(packageUri, targetUri);
PackagePart targetPart = package.GetPart(targetUri);View on GitHub (pinned to 81131a70a4)