dotnet/wpf · error · XpsSerializationException

SR.ReachSerialization_WrongPropertyTypeForFixedPage

Error message

SR.ReachSerialization_WrongPropertyTypeForFixedPage

What it means

XpsOMFixedPageSerializer.PersistObjectData throws XpsSerializationException (SR.ReachSerialization_WrongPropertyTypeForFixedPage) when the FixedPage context is a simple value rather than a complex one. A FixedPage must be serialized as a complex node (containing visuals, canvas, glyphs, etc.); primitives are schema-invalid at that position.

Solutions

  1. Ensure the FixedPage object contains complex child content (UIElement visuals) rather than scalar values
  2. Fix the page model/classes so the tree walker sees a complex value at FixedPage positions
  3. Use WPF's FixedPage class directly instead of custom substitutes

Example fix

// before
page.SetValue(SimpleValueProperty, 42);
// after
var canvas = new Canvas();
page.Children.Add(canvas);
Defensive patterns

Strategy: validation

Validate before calling

if (page is FixedPage fp && fp.Children.Count > 0) serializer.Serialize(fp);
else throw new InvalidOperationException("FixedPage must contain complex content");

Type guard

bool IsComplexFixedPage(object o) => o is FixedPage f && f.Children.Count > 0;

Try / catch

try { serializer.Serialize(page); }
catch (XpsSerializationException ex) when (ex.Message.Contains("FixedPage")) { /* simple value at FixedPage position */ }

Prevention

When it happens

Trigger: OXPS serialization reaching a FixedPage whose SerializableObjectContext.IsComplexValue is false.

Common situations: Generating FixedPage content programmatically and assigning simple property values where child elements are required; malformed custom page classes.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsOMFixedPageSerializer.cs:108

        internal
        override
        void
        PersistObjectData(
            SerializableObjectContext serializableObjectContext
            )
        {
            Toolbox.EmitEvent(EventTrace.Event.WClientDRXSerializationBegin);
            ReachTreeWalker treeWalker;

            bool needEndVisual = BeginPersistObjectData(serializableObjectContext, out treeWalker);

            if (serializableObjectContext.IsComplexValue)
            {
                SerializeObjectCore(serializableObjectContext);
            }
            else
            {
                throw new XpsSerializationException(SR.ReachSerialization_WrongPropertyTypeForFixedPage);
            }

            EndPersistObjectData(needEndVisual, treeWalker);

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

        internal
        bool
        BeginPersistObjectData(SerializableObjectContext serializableObjectContext, out ReachTreeWalker treeWalker)
        {
            ArgumentNullException.ThrowIfNull(serializableObjectContext);

            _xpsOMSerializationManager.RegisterPageStart();


            if (serializableObjectContext.IsComplexValue)
            {

View on GitHub (pinned to 81131a70a4)