{"record":{"id":"248873954c91370c","repo":"dotnet/wpf","slug":"sr-reachserialization-wrongpropertytypeforpagecontent-248873","errorCode":null,"errorMessage":"SR.ReachSerialization_WrongPropertyTypeForPageContent","messagePattern":"SR\\.ReachSerialization_WrongPropertyTypeForPageContent","errorType":"exception","errorClass":"XpsSerializationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachPageContentSerializerAsync.cs","lineNumber":104,"sourceCode":"        /// </param>\n        internal\n        override\n        void\n        PersistObjectData(\n            SerializableObjectContext   serializableObjectContext\n            )\n        {\n            if(serializableObjectContext.IsComplexValue)\n            {\n                ReachSerializerContext context = new ReachSerializerContext(this,\n                                                                            serializableObjectContext,\n                                                                            SerializerAction.serializePage);\n\n                ((IXpsSerializationManagerAsync)SerializationManager).OperationStack.Push(context);\n            }\n            else\n            {\n                throw new XpsSerializationException(SR.ReachSerialization_WrongPropertyTypeForPageContent);\n            }\n        }\n\n        private\n        void\n        SerializePage(\n            SerializableObjectContext   serializableObjectContext\n            )\n        {\n            FixedPage fixedPage = Toolbox.GetPageRoot(serializableObjectContext.TargetObject);\n\n            if(fixedPage != null)\n            {\n                ReachSerializer serializer = SerializationManager.GetSerializer(fixedPage);\n\n                if(serializer!=null)\n                {\n                    XpsSerializationPrintTicketRequiredEventArgs e = ","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachPageContentSerializerAsync.cs#L86-L122","documentation":"Async variant of 3735: ReachPageContentSerializerAsync.PersistObjectData throws XpsSerializationException(SR.ReachSerialization_WrongPropertyTypeForPageContent) when the target object of the context is not a PageContent. Only PageContent instances may be pushed onto the async OperationStack with SerializerAction.serializePage.","triggerScenarios":"Async XPS save where PersistObjectData receives a SerializableObjectContext whose TargetObject is not PageContent — e.g. a FixedPage or collection handed to the async page serializer.","commonSituations":"Custom async serialization pipelines in XpsSerializationManagerAsync; wrong node pushed to OperationStack; type changes in document-tree walking code.","solutions":["Pass a PageContent to ReachPageContentSerializerAsync","Use the async collection serializer for PageContent collections","Correct the OperationStack context construction so the target is the PageContent node","Add a pre-push type assertion in custom pipeline code"],"exampleFix":"// before\n((IXpsSerializationManagerAsync)SerializationManager).OperationStack.Push(\n    new SerializableObjectContext(fixedPage, \"PageContent\")); // wrong type\n// after\n((IXpsSerializationManagerAsync)SerializationManager).OperationStack.Push(\n    new SerializableObjectContext((PageContent)target, \"PageContent\"));","handlingStrategy":"type-guard","validationCode":"if (ctx.TargetObject is not PageContent) throw new ArgumentException(\"Async page serializer requires PageContent\");","typeGuard":"bool IsAsyncPageTarget(SerializableObjectContext c) => c?.TargetObject is PageContent;","tryCatchPattern":null,"preventionTips":["Assert type before pushing SerializerAction.serializePage","Keep sync and async walkers type-consistent","Cover async save in integration tests"],"tags":["wpf","xps-serialization","async","type-mismatch"],"backgroundTag":"incompatible-source-type","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"}