dotnet/wpf · error · XpsSerializationException
Serialized PageContent is not a complex property.
Error message
Serialized PageContent is not a complex property.
What it means
NGCPageContentSerializerAsync.PersistObjectData requires the serialized object context to be a complex property. When the PageContent context is not a complex property (wrong property kind for a page), it throws XpsSerializationException 'Serialized PageContent is not a complex property'.
Solutions
- Serialize PageContent as part of the normal FixedDocument/FixedPage serialization flow
- Ensure the manager pushes a complex-property context for PageContent
- Avoid manually constructing contexts; use the standard serialization manager entry points
Defensive patterns
Strategy: try-catch
Try / catch
try
{
manager.SaveAsXaml(pageContent);
}
catch (XpsSerializationException ex) when (ex.Message.Contains("complex property"))
{
// use standard document walk instead of manual contexts
} Prevention
- Avoid manually constructing serialization contexts; use SaveAsXaml entry points
- Serialize PageContent through FixedDocument rather than directly
When it happens
Trigger: Asynchronously serializing a PageContent whose object context was created as a non-complex (simple/dependency) property instead of a complex property context.
Common situations: Internal routing bugs in custom serialization managers, or calling SaveAsXaml with an object whose context construction skipped the complex-property path (e.g. serializing page content outside a FixedDocument walk).
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Cannot find the appropriate serializer.
- Cannot find the appropriate serializer.
- Cannot find the appropriate serializer.
- Cannot instantiate a serializer of the given type.
- CurrentFixedPageWriter uninitialized
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/b0561182f83e1ee4.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/NGCPageContentSerializerAsync.cs:104
/// </param>
internal
override
void
PersistObjectData(
SerializableObjectContext serializableObjectContext
)
{
if(serializableObjectContext.IsComplexValue)
{
NGCSerializerContext context = new NGCSerializerContext(this,
serializableObjectContext,
SerializerAction.serializePage);
((NgcSerializationManagerAsync)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)
{
NgcSerializationManagerAsync manager = SerializationManager as NgcSerializationManagerAsync;View on GitHub (pinned to 81131a70a4)