dotnet/wpf · error · ArgumentException

" }} " element found. Expected fixed page element ( }} ).

Error message

"{{{0}}}{1}" element found. Expected fixed page element ({{{2}}}{3}).

What it means

XmlFixedPageInfo's constructor only accepts an XML node that is a FixedPage element in the FixedMarkup namespace. If the passed node has a different LocalName or NamespaceURI, the constructor throws ArgumentException because it would otherwise silently build inconsistent page metadata.

Solutions

  1. Verify the node's LocalName equals "FixedPage" and its NamespaceURI equals ElementTableKey.FixedMarkupNamespace before constructing XmlFixedPageInfo
  2. Navigate the XML tree to the actual FixedPage element instead of passing a container node such as FixedDocument
  3. Fix namespace declarations in the XPS markup if the FixedPage is emitted under an incorrect namespace

Example fix

// before
var info = new XmlFixedPageInfo(doc.DocumentElement);
// after
var root = doc.DocumentElement;
if (root.LocalName == "FixedPage" && root.NamespaceURI == fixedMarkupNs)
{
    var info = new XmlFixedPageInfo(root);
}
Defensive patterns

Strategy: validation

Validate before calling

if (node == null) throw new ArgumentNullException(nameof(node));
if (node.LocalName != "FixedPage" || node.NamespaceURI != fixedMarkupNs)
    throw new ArgumentException($"Expected FixedPage element, got {node.NamespaceURI}:{node.LocalName}");

Type guard

static bool IsFixedPage(XmlNode n) =>
    n != null && n.LocalName == "FixedPage" &&
    n.NamespaceURI == "http://schemas.microsoft.com/xps/2005/06";

Try / catch

try { var info = new XmlFixedPageInfo(node); }
catch (ArgumentException ex) { /* log node.LocalName/NamespaceURI and skip part */ }

Prevention

When it happens

Trigger: Calling new XmlFixedPageInfo(node) with a node that is not a <FixedPage> in the fixed markup namespace — e.g. a FixedDocument, FixedDocumentSequence, or a FixedPage in the wrong namespace.

Common situations: Parsing XPS document parts generically and passing whatever XmlNode is found at the part root, or handling XPS packages where the FixedPage element is emitted under a mistyped/legacy namespace.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XmlFixedPageInfo.cs:37

        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors
        /// <summary>
        /// Initialize object from DOM node.
        /// </summary>
        /// <remarks>
        /// The DOM node is assumed to be a XAML FixedPage element. Its namespace URI
        /// is subsequently used to look for its nested Glyphs elements (see private property NodeList).
        /// </remarks>
        internal XmlFixedPageInfo(XmlNode fixedPageNode)
        {
            _pageNode = fixedPageNode;
            Debug.Assert(_pageNode != null);
            if (_pageNode.LocalName != _fixedPageName || _pageNode.NamespaceURI != ElementTableKey.FixedMarkupNamespace)
            {
                throw new ArgumentException(SR.Format(SR.UnexpectedXmlNodeInXmlFixedPageInfoConstructor,
                    _pageNode.NamespaceURI, _pageNode.LocalName,
                    ElementTableKey.FixedMarkupNamespace, _fixedPageName));
            }
        }
        #endregion Constructors

        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods
        /// <summary>
        /// Get the glyph run at zero-based position 'position'.
        /// </summary>
        /// <remarks>
        /// Returns null for a nonexistent position. No exception raised.

View on GitHub (pinned to 81131a70a4)