dotnet/wpf · error · XpsSerializationException

Cannot find the appropriate serializer.

Error message

Cannot find the appropriate serializer.

What it means

While serializing an individual PageContent, NGCPageContentCollectionSerializerAsync looks up a serializer for the page content's type via the serialization manager. If the manager cannot supply a ReachSerializer for that type, it throws XpsSerializationException 'Cannot find the appropriate serializer'.

Solutions

  1. Ensure the object serialized is a standard PageContent/FixedPage structure
  2. Register a serializer for the custom type with the serialization manager
  3. Check that you are using the NGC async manager with supported types (FixedPage etc.)
Defensive patterns

Strategy: try-catch

Type guard

bool HasKnownSerializer(object o, XpsSerializationManager m) =>
    m.GetSerializerFor(o.GetType()) != null;

Try / catch

try
{
    manager.SaveAsXaml(pageContents);
}
catch (XpsSerializationException ex) when (ex.Message.Contains("serializer"))
{
    // register a serializer for the unsupported type or fix object graph
}

Prevention

When it happens

Trigger: Serializing a PageContent whose inner object type has no registered/mapped serializer in the managers' type-to-serializer map (e.g. a non-standard object inside PageContent).

Common situations: Custom document structures or objects placed in a page content collection that the XPS serializer framework does not recognize.

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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/NGCPageContentCollectionSerializerAsync.cs:210

        /// </summary>
        /// <param name="pageContent">
        /// The PageContent to be serialized.
        /// </param>
        private 
        void 
        SerializePageContent(
            object pageContent
            )
        {
            ReachSerializer serializer = SerializationManager.GetSerializer(pageContent);

            if(serializer!=null)
            {
                serializer.SerializeObject(pageContent);
            }
            else
            {
                throw new XpsSerializationException(SR.ReachSerialization_NoSerializer);
            }
        }

        #endregion Private Methods
    };

    internal class NgcPageContentCollectionSerializerContext :
                   NGCSerializerContext
    {
        public
        NgcPageContentCollectionSerializerContext(
            NGCSerializerAsync          serializer,
            SerializableObjectContext   objectContext,
            IEnumerator                 enumerator,
            SerializerAction            action
            ):
            base(serializer,objectContext,action)
        {

View on GitHub (pinned to 81131a70a4)