{"record":{"id":"bee4b4fe2690fb02","repo":"dotnet/wpf","slug":"sr-reachserialization-wrongpropertytypeforpagecontent","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/ReachPageContentSerializer.cs","lineNumber":95,"sourceCode":"                        if( e.Modified )\n                        {\n                            printTicket =  e.PrintTicket;\n                        }\n                        Toolbox.Layout(fixedPage, printTicket);\n                        \n                        ((IXpsSerializationManager)SerializationManager).FixedPagePrintTicket = printTicket;\n\n                        serializer.SerializeObject(fixedPage);\n                    }\n                    else\n                    {\n                        throw new XpsSerializationException(SR.ReachSerialization_NoSerializer);\n                    }\n                }\n            }\n            else\n            {\n                throw new XpsSerializationException(SR.ReachSerialization_WrongPropertyTypeForPageContent);\n            }\n        }\n\n        #endregion Internal Methods\n    };\n}\n","sourceCodeStart":77,"sourceCodeEnd":102,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachPageContentSerializer.cs#L77-L102","documentation":"ReachPageContentSerializer.PersistObjectData throws XpsSerializationException(SR.ReachSerialization_WrongPropertyTypeForPageContent) when the SerializableObjectContext's target object is not a PageContent (the expected property type). This serializer exists solely for PageContent objects; anything else is invalid input to it.","triggerScenarios":"Calling SerializeObject on ReachPageContentSerializer with a target that is not System.Windows.Documents.PageContent — e.g. a FixedPage directly, a UIElement, or a collection (which belongs to the collection serializer).","commonSituations":"Custom serialization drivers invoking page-level serializer with the wrong node of the document tree; refactorings that changed which serializer handles which type; manual context construction with wrong TargetObject.","solutions":["Ensure the object passed to ReachPageContentSerializer is a PageContent instance","Use ReachPageContentCollectionSerializer for collections and the FixedPage serializer for FixedPage objects","Fix the context construction so TargetObject is the PageContent node","Check custom serializer-to-type registrations for mismatches"],"exampleFix":"// before\nvar serializer = new ReachPageContentSerializer(manager);\nserializer.SerializeObject(fixedPage); // wrong type\n// after\nserializer.SerializeObject(pageContent); // PageContent wraps the FixedPage\nserializer.SerializeObject(((PageContent)target).Child == null ? pageContent : pageContent);","handlingStrategy":"type-guard","validationCode":"if (target is not PageContent) throw new ArgumentException(\"ReachPageContentSerializer requires a PageContent\");","typeGuard":"bool IsPageContent(object o) => o is PageContent;","tryCatchPattern":null,"preventionTips":["Match serializer to node type explicitly","Assert target type at the top of custom PersistObjectData overrides","Keep a table mapping document-tree node types to serializers"],"tags":["wpf","xps-serialization","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-22T01:17:13.364Z"}