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

  1. Pass a supported serializable type (Visual, FixedPage, FixedDocument, FixedDocumentSequence) to SaveAsXaml.
  2. Wrap unsupported content in a container that IS serializable, e.g. place the element in a FixedPage or use a VisualsCollator.
  3. 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

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


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 queue

View on GitHub (pinned to 81131a70a4)