{"record":{"id":"ca5f23b0a511bd8b","repo":"dotnet/wpf","slug":"sr-xpsvalidatingloaderprinttickethasincorrecttype","errorCode":null,"errorMessage":"SR.XpsValidatingLoaderPrintTicketHasIncorrectType","messagePattern":"SR\\.XpsValidatingLoaderPrintTicketHasIncorrectType","errorType":"exception","errorClass":"FileFormatException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedSchema.cs","lineNumber":561,"sourceCode":"            checkRels = part.GetRelationshipsByType(_printTicketRel);\n            count = 0;\n            foreach (PackageRelationship rel in checkRels)\n            {\n                count++;\n                if (count > 1)\n                {\n                    throw new FileFormatException(SR.XpsValidatingLoaderMoreThanOnePrintTicketPart);\n                }\n\n                // Also check for existence and type\n                Uri targetUri = PackUriHelper.ResolvePartUri(partUri, rel.TargetUri);\n                Uri absTargetUri = PackUriHelper.Create(packageUri, targetUri);\n\n                PackagePart targetPart = package.GetPart(targetUri);\n\n                if (!_printTicketContentType.AreTypeAndSubTypeEqual(new ContentType(targetPart.ContentType)))\n                {\n                    throw new FileFormatException(SR.XpsValidatingLoaderPrintTicketHasIncorrectType);\n                }\n            }\n\n            checkRels = part.GetRelationshipsByType(_thumbnailRel);\n            count = 0;\n            foreach (PackageRelationship rel in checkRels)\n            {\n                count++;\n                if (count > 1)\n                {\n                    throw new FileFormatException(SR.XpsValidatingLoaderMoreThanOneThumbnailPart);\n                }\n\n                // Also check for existence and type\n                Uri targetUri = PackUriHelper.ResolvePartUri(partUri, rel.TargetUri);\n                Uri absTargetUri = PackUriHelper.Create(packageUri, targetUri);\n\n                PackagePart targetPart = package.GetPart(targetUri);","sourceCodeStart":543,"sourceCodeEnd":579,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedSchema.cs#L543-L579","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nPackagePart ticket = pkg.CreatePart(ticketUri, \"application/xml\");\n// after\nPackagePart ticket = pkg.CreatePart(ticketUri, \"application/vnd.ms-printing.printticket+xml\");","handlingStrategy":"validation","validationCode":"const string printTicketType = \"application/vnd.ms-printing.printticket+xml\";\nforeach (var rel in fixedPart.GetRelationshipsByType(printTicketRel)) {\n    var target = package.GetPart(PackUriHelper.ResolvePartUri(fixedPart.Uri, rel.TargetUri));\n    if (!target.ContentType.Equals(printTicketType, StringComparison.OrdinalIgnoreCase))\n        throw new InvalidDataException($\"PrintTicket rel target {target.Uri} has wrong type {target.ContentType}\");\n}","typeGuard":"static bool IsPrintTicketPart(PackagePart p) =>\n    p.ContentType.Equals(\"application/vnd.ms-printing.printticket+xml\", StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try { loader.Load(packageStream); }\ncatch (FileFormatException ex) { // wrong ticket target type: fix [Content_Types].xml or retarget rel, then retry\n    FixPrintTicketContentTypes(packageStream); loader.Load(packageStream); }","preventionTips":["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."],"tags":["xps","printticket","content-type","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}