{"record":{"id":"801d7ff662725c9a","repo":"dotnet/wpf","slug":"sr-reachserialization-wrongpropertytypeforfixedpage-801d7f","errorCode":null,"errorMessage":"SR.ReachSerialization_WrongPropertyTypeForFixedPage","messagePattern":"SR\\.ReachSerialization_WrongPropertyTypeForFixedPage","errorType":"exception","errorClass":"XpsSerializationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedPageSerializerAsync.cs","lineNumber":242,"sourceCode":"                                                                                         treeWalker);\n\n                    ((IXpsSerializationManagerAsync)SerializationManager).OperationStack.Push(context);\n\n                    PrintTicket printTicket = ((IXpsSerializationManager)SerializationManager).FixedPagePrintTicket;\n                    \n                    if(printTicket != null)\n                    {\n                        PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);\n                        serializer.SerializeObject(printTicket);\n                        ((IXpsSerializationManager)SerializationManager).FixedPagePrintTicket = null;\n                    }\n\n\n                    SerializeObjectCore(serializableObjectContext);\n                }\n                else\n                {\n                    throw new XpsSerializationException(SR.ReachSerialization_WrongPropertyTypeForFixedPage);\n                }\n\n            }\n        }\n\n        /// <summary>\n        /// This method is the one that writes out the attribute within\n        /// the xml stream when serializing simple properties.\n        /// </summary>\n        /// <param name=\"serializablePropertyContext\">\n        /// The property that is to be serialized as an attribute at this time.\n        /// </param>\n        internal\n        override\n        void\n        WriteSerializedAttribute(\n            SerializablePropertyContext serializablePropertyContext\n            )","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedPageSerializerAsync.cs#L224-L260","documentation":"Async counterpart of 3725: ReachFixedPageSerializerAsync.PersistObjectData throws XpsSerializationException (ReachSerialization_WrongPropertyTypeForFixedPage) when the object context is not a FixedPage. The async page serializer enforces the same type contract before SerializeObjectCore, aborting the async write otherwise.","triggerScenarios":"Async XPS write routes a non-FixedPage object to the async page serializer's PersistObjectData.","commonSituations":"WriteAsync with a tree containing plain Visuals or custom controls in page position; migrations from sync to async serialization that changed node types.","solutions":["Guarantee FixedPage instances occupy page positions in the graph","Add a runtime type check before calling WriteAsync","Catch XpsSerializationException and inspect the failing node type"],"exampleFix":"// before\nawait Task.Run(() => writer.WriteAsync(node));\n// after\nif (node is FixedPage page) { writer.WriteAsync(page); }","handlingStrategy":"type-guard","validationCode":"bool ok = node is System.Windows.Documents.FixedPage;","typeGuard":"static bool IsFixedPage(object o) => o is System.Windows.Documents.FixedPage;","tryCatchPattern":"try { writer.WriteAsync(page); } catch (System.Windows.Xps.XpsSerializationException ex) { log.Error(ex); throw; }","preventionTips":["is-FixedPage check before WriteAsync","Keep page nodes as FixedPage instances","Cover async writes with graph-shape 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"}