dotnet/wpf · error · XpsSerializationException
SR.ReachSerialization_NotSupported
Error message
SR.ReachSerialization_NotSupported
What it means
XpsSerializationManagerAsync.SaveAsXaml validates that the object type being serialized is supported before starting async XPS serialization. If the object's type is not in the supported set, it throws XpsSerializationException with SR.ReachSerialization_NotSupported. The library only knows how to serialize a fixed set of types (Visuals, FixedDocument/Sequence, containers, etc.).
Solutions
- Pass a supported serializable type (Visual, FixedPage, FixedDocument, FixedDocumentSequence) to SaveAsXaml.
- Wrap unsupported content in a container that IS serializable, e.g. place the element in a FixedPage or use a VisualsCollator.
- Pre-check the object type against supported types before calling SaveAsXaml.
Example fix
// before manager.SaveAsXaml(myCustomBusinessObject); // after FixedPage page = LayoutAsFixedPage(myVisual); manager.SaveAsXaml(page);
Defensive patterns
Strategy: validation
Validate before calling
bool IsSupported(object o) => o is Visual || o is FixedDocument || o is FixedDocumentSequence || o is FixedPage;
if (!IsSupported(obj)) throw new ArgumentException("Type not serializable to XPS", nameof(obj)); Type guard
bool IsXpsSerializable(object o) => o is Visual || o is FixedDocument || o is FixedDocumentSequence;
Prevention
- Only pass Visual/FixedDocument/FixedDocumentSequence/FixedPage objects to SaveAsXaml.
- Wrap arbitrary UI content in a FixedPage or use XpsDocumentWriter.Write(Visual).
- Add a pre-serialization type assert in dev builds.
When it happens
Trigger: Calling SaveAsXaml with a serializedObject whose type fails IsSerializedObjectTypeSupported (after passing the null check) — e.g. passing an arbitrary business object or unsupported DependencyObject.
Common situations: Developers try to SaveAsXaml a custom control, a Window, or a plain data object instead of a Visual/FixedDocument/FixedPage, expecting generic object serialization.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot find the appropriate serializer.
- Serialization of this type of object is not supported.
- Serialization of this type of object is not supported.
- Serialization of this type of object is not supported.
- SR.ReachSerialization_NoSerializer
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/8d2f8d15d83ec102.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsSerializationManagerAsync.cs:69
/// <summary>
///
/// </summary>
/// <exception cref="ArgumentNullException">serializedObject is NULL.</exception>
/// <exception cref="XpsSerializationException">serializedObject is not a supported type.</exception>
public
override
void
SaveAsXaml(
Object serializedObject
)
{
ArgumentNullException.ThrowIfNull(serializedObject);
if (!IsSerializedObjectTypeSupported(serializedObject))
{
throw new XpsSerializationException(SR.ReachSerialization_NotSupported);
}
if(Simulator == null)
{
Simulator = new ReachHierarchySimulator(this,
serializedObject);
}
if(!IsSimulating)
{
Simulator.BeginConfirmToXPSStructure(IsBatchMode);
IsSimulating = true;
}
if(IsBatchMode)
{
//
// Add the Visual received in to the queueView on GitHub (pinned to 81131a70a4)