dotnet/wpf · error · XpsSerializationException
SR.ReachSerialization_WrongPropertyTypeForFixedDocument
Error message
SR.ReachSerialization_WrongPropertyTypeForFixedDocument
What it means
XpsOMFixedDocumentSerializer.PersistObjectData throws XpsSerializationException (SR.ReachSerialization_WrongPropertyTypeForFixedDocument) when the SerializableObjectContext holds a simple (non-complex) value. FixedDocument nodes must be serialized as complex values (containing child objects like FixedPage references); a primitive/leaf property at a FixedDocument position is invalid in the XPS schema.
Solutions
- Ensure the object serialized as a FixedDocument exposes complex child properties (FixedPage collection), not simple values
- Fix the data model so the FixedDocument position holds a proper container type
- Use the standard FixedDocument/FixedDocumentSequence classes instead of custom stand-ins
Example fix
// before doc.SetCurrentValue(MyFixedDocumentProperty, "simple value"); // after doc.SetCurrentValue(MyFixedDocumentProperty, new FixedDocument());
Defensive patterns
Strategy: validation
Validate before calling
bool IsComplexFixedDocument(object doc) =>
doc is FixedDocument || (doc != null && HasComplexChildren(doc)); Type guard
bool IsFixedDocumentContainer(object o) => o is System.Windows.Documents.FixedDocument;
Try / catch
try { serializer.Serialize(doc); }
catch (XpsSerializationException ex) when (ex.Message.Contains("FixedDocument")) { /* schema violation: simple value at FixedDocument position */ } Prevention
- Model FixedDocuments with child PageContent/FixedPage collections only
- Use standard WPF FixedDocument types in serialization graphs
- Validate document structure with the XPS schema before serializing
When it happens
Trigger: Serializing an object graph where a FixedDocument-level context reports IsComplexValue == false — i.e., the tree walker reached a simple property where a FixedDocument container was expected.
Common situations: Custom XPS document structures that violate the FixedDocument schema; wrongly typed roots fed to the OXPS serializer; reflection-based tree walkers misreporting property types.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 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/cb5b52551df6ae56.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsOMFixedDocumentSerializer.cs:93
_xpsOMSerializationManager.ResourcePolicy.ColorContextTable = new Dictionary<int, Uri>();
}
internal
override
void
PersistObjectData(
SerializableObjectContext serializableObjectContext
)
{
BeginPersistObjectData(serializableObjectContext);
if (serializableObjectContext.IsComplexValue)
{
SerializeObjectCore(serializableObjectContext);
}
else
{
throw new XpsSerializationException(SR.ReachSerialization_WrongPropertyTypeForFixedDocument);
}
EndPersistObjectData();
}
internal
void
BeginPersistObjectData(
SerializableObjectContext serializableObjectContext
)
{
ArgumentNullException.ThrowIfNull(serializableObjectContext);
_xpsOMSerializationManager.RegisterDocumentStart();
if (serializableObjectContext.IsComplexValue)
{
XpsSerializationPrintTicketRequiredEventArgs e =View on GitHub (pinned to 81131a70a4)