{"record":{"id":"727a6dd91e3632e1","repo":"dotnet/wpf","slug":"sr-reachserialization-wrongpropertytypeforfixeddocument-727a6d","errorCode":null,"errorMessage":"SR.ReachSerialization_WrongPropertyTypeForFixedDocument","messagePattern":"SR\\.ReachSerialization_WrongPropertyTypeForFixedDocument","errorType":"exception","errorClass":"XpsSerializationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedDocumentSerializerAsync.cs","lineNumber":202,"sourceCode":"                    ((IXpsSerializationManager)SerializationManager).OnXPSSerializationPrintTicketRequired(e);\n\n                    //\n                    // Serialize the data for the PrintTicket\n                    //\n                    if(e.Modified)\n                    {\n                        if(e.PrintTicket != null)\n                        {\n                            PrintTicketSerializerAsync serializer = new PrintTicketSerializerAsync(SerializationManager);\n                            serializer.SerializeObject(e.PrintTicket);\n                        }\n                    }\n\n                    SerializeObjectCore(serializableObjectContext);\n                }\n                else\n                {\n                    throw new XpsSerializationException(SR.ReachSerialization_WrongPropertyTypeForFixedDocument);\n                }\n            }\n        }\n\n        internal\n        override\n        void\n        EndPersistObjectData(\n            )\n        {\n            //\n            // Clear off the table from the packaging policy\n            //\n            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageCrcTable = null;\n            \n            ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageUriHashTable = null;\n\n","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedDocumentSerializerAsync.cs#L184-L220","documentation":"Async version of error 3723: ReachFixedDocumentSerializerAsync.PersistObjectData throws XpsSerializationException when the context object is not the FixedDocument type it requires. It fails fast before SerializeObjectCore so that malformed graphs never produce a partially written async XPS package.","triggerScenarios":"WriteAsync path routes an object to the async FixedDocument serializer whose SerializableObjectContext.TargetObject is not a FixedDocument.","commonSituations":"Same as sync case: manual object trees, FixedPage placed where FixedDocument is expected, custom subclasses changing the expected runtime type during async writes.","solutions":["Verify the object passed to WriteAsync is a FixedDocument","Nest FixedPage content inside PageContent entries of document.Pages","Catch XpsSerializationException and run a type audit of the visual/document tree"],"exampleFix":"// before\nif (!(obj is FixedDocument)) { /* serialized anyway */ }\n// after\nif (obj is FixedDocument doc) { xpsWriter.WriteAsync(doc); }","handlingStrategy":"type-guard","validationCode":"bool ok = obj is System.Windows.Documents.FixedDocument;","typeGuard":"static bool IsFixedDocument(object o) => o is System.Windows.Documents.FixedDocument;","tryCatchPattern":"try { writer.WriteAsync(doc); } catch (System.Windows.Xps.XpsSerializationException ex) { log.Error(ex); throw; }","preventionTips":["Guard WriteAsync input with an is-FixedDocument check","Avoid custom document types unless registered","Keep async path covered by serialization tests"],"tags":["xps","wpf","serialization","type-mismatch","async","dotnet"],"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"}