dotnet/wpf · error · XpsSerializationException

SR.ReachSerialization_NoSerializer

Error message

SR.ReachSerialization_NoSerializer

What it means

XpsSerializationManager.SaveAsXaml throws XpsSerializationException with SR.ReachSerialization_NoSerializer when GetSerializer(serializedObject) returns null, i.e. the type passed the root-type check but no ReachSerializer is registered for its concrete type. The manager cannot find a serializer to drive the object graph.

Solutions

  1. Serialize concrete, non-derived FixedDocumentSequence/FixedDocument/FixedPage instances rather than custom subclasses.
  2. Register a ReachSerializer for the custom type via the serializer provider/manager if custom types are required.
  3. Inspect GetSerializer's type mapping and confirm the runtime type passed (GetType(), not declared type).
  4. Unwrap paginators correctly so the underlying FixedDocument/FixedDocumentSequence is what gets serialized.

Example fix

// before: subclass has no serializer
manager.SaveAsXaml(new MyCustomPage());

// after: build standard page from the subclass content
var page = new FixedPage();
foreach (var child in myCustomPage.Children) FixedPage.Children.Add(page, child);
manager.SaveAsXaml(page);
Defensive patterns

Strategy: try-catch

Validate before calling

// concrete type must map to a registered ReachSerializer
bool serializerExists = manager.GetSerializer(root) is not null; // if accessible

Type guard

static bool HasConcreteSerializer(object o) => o.GetType() == typeof(FixedDocumentSequence) || o.GetType() == typeof(FixedDocument) || o.GetType() == typeof(FixedPage);

Try / catch

try { manager.SaveAsXaml(obj); }
catch (XpsSerializationException ex) { /* no serializer for concrete type; rebuild as standard FixedDocument/FixedPage */ }

Prevention

When it happens

Trigger: Calling SaveAsXaml with a supported-looking root whose concrete/runtime type has no registered ReachSerializer (e.g., a custom subclass of FixedDocument/FixedPage that lacks serializer metadata), or with a paginator wrapper that resolves to an unexpected source type.

Common situations: Subclassing FixedPage/FixedDocument and passing the subclass to SaveAsXaml; custom serializers removed or not registered in the serializer provider; version differences where a type lost its serializer mapping.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/e1e054384499e80f. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsSerializationManager.cs:154

                //
                // Things that need to be done at this stage
                // 1. Setting the stack context
                // 2. Setting the root of the graph for future references
                //
                reachSerializer.SerializeObject(serializedObject);

                if(_isBatchMode)
                {
                    _simulator.SimulateEndFixedPage(pageXmlWriter);
                }
                else
                {
                    _simulator.EndConfirmToXPSStructure(_isBatchMode);
                }
            }
            else
            {
                throw new XpsSerializationException(SR.ReachSerialization_NoSerializer);
            }

            Toolbox.EmitEvent(EventTrace.Event.WClientDRXSaveXpsEnd);
        }

        /// <summary>
        ///
        /// </summary>
        public
        virtual
        void
        Commit(
            )
        {
            if(_isBatchMode && _isSimulating)
            {
                _simulator.EndConfirmToXPSStructure(_isBatchMode);
            }

View on GitHub (pinned to 81131a70a4)