dotnet/wpf · error · XpsSerializationException

Cannot find the appropriate serializer.

Error message

Cannot find the appropriate serializer.

What it means

In SerializePage, NGCPageContentSerializerAsync looks up the serializer for the FixedPage type. If the serialization manager returns null (no serializer registered for FixedPage), it throws XpsSerializationException 'Cannot find the appropriate serializer'.

Solutions

  1. Use the standard ReachFramework serialization manager which has FixedPage serializer mappings
  2. Register a serializer for the failing type
  3. Verify the PageContent content is an actual FixedPage
Defensive patterns

Strategy: try-catch

Type guard

bool IsFixedPage(PageContent pc) => pc is PageContent;

// and pre-check:
bool serializerExists = manager.GetSerializerFor(typeof(FixedPage)) != null;

Try / catch

try
{
    manager.SaveAsXaml(pageContent);
}
catch (XpsSerializationException ex) when (ex.Message.Contains("serializer"))
{
    // ensure FixedPage serializer mapping exists on the manager
}

Prevention

When it happens

Trigger: Serializing a page where the manager's type map has no ReachSerializer for FixedPage (or the resolved type inside the PageContent is unrecognized).

Common situations: Custom or misconfigured NGCSerializationManagerAsync instances lacking the ReachFramework serializer mappings, or a PageContent containing an unexpected child object type.

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/fcdfc944d09fdb93. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/NGCPageContentSerializerAsync.cs:135

            {
                ReachSerializer serializer = SerializationManager.GetSerializer(fixedPage);

                if(serializer!=null)
                {
                    NgcSerializationManagerAsync manager = SerializationManager as NgcSerializationManagerAsync;
                    
                    XpsSerializationPrintTicketRequiredEventArgs e = 
                        new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedPagePrintTicket,
                                                         0);
                    manager.OnNGCSerializationPrintTicketRequired(e);

                    Toolbox.Layout(fixedPage, manager.GetActivePrintTicket());

                    serializer.SerializeObject(fixedPage);
                }
                else
                {
                    throw new XpsSerializationException(SR.ReachSerialization_NoSerializer);
                }
            }

        }

        #endregion Internal Methods
    };
}

View on GitHub (pinned to 81131a70a4)