dotnet/wpf · error · XpsSerializationException
SR.ReachSerialization_WrongPropertyTypeForPageContent
Error message
SR.ReachSerialization_WrongPropertyTypeForPageContent
What it means
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.
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
Example fix
// before
((IXpsSerializationManagerAsync)SerializationManager).OperationStack.Push(
new SerializableObjectContext(fixedPage, "PageContent")); // wrong type
// after
((IXpsSerializationManagerAsync)SerializationManager).OperationStack.Push(
new SerializableObjectContext((PageContent)target, "PageContent")); Defensive patterns
Strategy: type-guard
Validate before calling
if (ctx.TargetObject is not PageContent) throw new ArgumentException("Async page serializer requires PageContent"); Type guard
bool IsAsyncPageTarget(SerializableObjectContext c) => c?.TargetObject is PageContent;
Prevention
- Assert type before pushing SerializerAction.serializePage
- Keep sync and async walkers type-consistent
- Cover async save in integration tests
When it happens
Trigger: 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.
Common situations: Custom async serialization pipelines in XpsSerializationManagerAsync; wrong node pushed to OperationStack; type changes in document-tree walking code.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- SR.MustBeOfType
- SR.ReachSerialization_TargetNotPrintTicket
- SR.Format(SR.MustBeOfType…
- SR.MustBeOfType
- SR.MustBeOfType
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/248873954c91370c.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachPageContentSerializerAsync.cs:104
/// </param>
internal
override
void
PersistObjectData(
SerializableObjectContext serializableObjectContext
)
{
if(serializableObjectContext.IsComplexValue)
{
ReachSerializerContext context = new ReachSerializerContext(this,
serializableObjectContext,
SerializerAction.serializePage);
((IXpsSerializationManagerAsync)SerializationManager).OperationStack.Push(context);
}
else
{
throw new XpsSerializationException(SR.ReachSerialization_WrongPropertyTypeForPageContent);
}
}
private
void
SerializePage(
SerializableObjectContext serializableObjectContext
)
{
FixedPage fixedPage = Toolbox.GetPageRoot(serializableObjectContext.TargetObject);
if(fixedPage != null)
{
ReachSerializer serializer = SerializationManager.GetSerializer(fixedPage);
if(serializer!=null)
{
XpsSerializationPrintTicketRequiredEventArgs e = View on GitHub (pinned to 81131a70a4)