dotnet/wpf · error · XmlException

Cannot nest FixedPage in FixedPage.

Error message

Cannot nest FixedPage in FixedPage.

What it means

ArgumentException from XamlFilter.ProcessFixedPage: a FixedPage element was encountered nested inside another FixedPage, which is not a legal fixed-document structure, so the incremental content extractor refuses to load the inner page.

Solutions

  1. Correct the document structure so FixedPage elements are not nested
  2. Re-generate the XPS/fixed document from a valid source
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XamlFilter.cs:779 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XamlFilter.cs:779

            uint lcid = GetCurrentLcid();
            SkipCurrentElement();
            return BuildIndexingContentUnit(textContent, lcid);
        }

        /// <summary>
        /// Load FixedPage element into a DOM tree to initialize a FixedPageContentExtractor.
        /// The content extractor will then be used to incrementally return the content of the fixed page.
        /// </summary>
        private IndexingContentUnit ProcessFixedPage()
        {
            // Reader is positioned on the start-tag for a FixedPage element.
            Debug.Assert(string.Equals(_xamlReader.LocalName, _fixedPageName, StringComparison.Ordinal));

            // A FixedPage nested in a FixedPage is invalid.
            // XmlException gets handled inside this class (see GetChunk).
            if (_filterState == FilterState.FindNextFlowUnit)
            {
                throw new XmlException(SR.XamlFilterNestedFixedPage);
            }

            // Create a DOM for the current FixedPage.
            string fixedPageMarkup = _xamlReader.ReadOuterXml();
            XmlDocument fixedPageTree = new XmlDocument();
            fixedPageTree.LoadXml(fixedPageMarkup);

            // Preserve the current language ID
            if (_xamlReader.XmlLang.Length > 0)
            {
                fixedPageTree.DocumentElement.SetAttribute(_xmlLangAttribute, _xamlReader.XmlLang);
            }

            // Initialize a content extractor with this DOM tree.
            _fixedPageContentExtractor = new FixedPageContentExtractor(fixedPageTree.DocumentElement);

            // Save the DOM (to search for flow elements in it once the extractor is done)
            // and switch to extractor mode.

View on GitHub (pinned to 81131a70a4)