{"record":{"id":"f72e3e1938380741","repo":"dotnet/wpf","slug":"sr-reachserialization-targetnotprintticket-f72e3e","errorCode":null,"errorMessage":"SR.ReachSerialization_TargetNotPrintTicket","messagePattern":"SR\\.ReachSerialization_TargetNotPrintTicket","errorType":"exception","errorClass":"XpsSerializationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachPrintTicketSerializerAsync.cs","lineNumber":63,"sourceCode":"        /// </summary>\n        /// <param name=\"serializedObject\">\n        /// Instance of object to be serialized.\n        /// </param>\n        public\n        override\n        void\n        SerializeObject(\n            object serializedObject\n            )\n        {\n            PrintTicket printTicket = serializedObject as PrintTicket;\n\n            if (printTicket == null)\n            {\n                //\n                // Throw a meaningful exception\n                //\n                throw new XpsSerializationException(SR.ReachSerialization_TargetNotPrintTicket);\n            }\n\n            ((XpsSerializationManagerAsync)SerializationManager).\n            PackagingPolicy.PersistPrintTicket(printTicket);\n        }\n\n        #endregion Public Methods\n\n        #region Internal Methods\n\n        /// <summary>\n        /// The main method that is called to serialize the PrintTicket\n        /// and that is usually called from within the serialization manager\n        /// when a node in the graph of objects is at a turn where it should\n        /// be serialized.\n        /// </summary>\n        /// <param name=\"serializedProperty\">\n        /// The context of the property being serialized at this time and","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachPrintTicketSerializerAsync.cs#L45-L81","documentation":"Async counterpart of 3738: ReachPrintTicketSerializerAsync.SerializeObject throws XpsSerializationException(SR.ReachSerialization_TargetNotPrintTicket) when the supplied object is null or not a PrintTicket. On success it forwards the PrintTicket to XpsSerializationManagerAsync.PackagingPolicy.PersistPrintTicket.","triggerScenarios":"Async save path (called via PersistObjectData/SerializeObject) where the object to serialize is null or of a type other than PrintTicket, e.g. a FixedPage or document sequence.","commonSituations":"Async XPS pipelines where the print ticket failed to build and null flowed into the serializer; wrong serializer chosen for the node; race where the ticket was disposed/set to null before the async operation ran.","solutions":["Ensure a valid non-null PrintTicket reaches the async serializer","Null-check the ticket before scheduling the async operation","Use the appropriate async serializer for non-ticket objects","Fix upstream PrintTicket creation/validation (e.g. PrintQueue.CreateXpsDocumentWriter flow)"],"exampleFix":"// before\nprintTicketSerializerAsync.SerializeObject(maybeNullTicket);\n// after\nif (maybeNullTicket is PrintTicket ticket)\n    printTicketSerializerAsync.SerializeObject(ticket);\nelse\n    throw new ArgumentException(\"A PrintTicket is required\");","handlingStrategy":"validation","validationCode":"if (obj is not PrintTicket) throw new ArgumentException(\"Async serializer requires a PrintTicket\");","typeGuard":"bool IsPrintTicket(object o) => o is PrintTicket;","tryCatchPattern":"try { printTicketSerializerAsync.SerializeObject(obj); } catch (XpsSerializationException ex) { /* not a PrintTicket or disposed before async run */ }","preventionTips":["Keep the ticket alive until the async operation completes","Validate ticket type before queueing","Centralize print-ticket creation to avoid null propagation"],"tags":["wpf","xps-serialization","async","print-ticket","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}