dotnet/wpf · error · ArgumentException

SR.SelectionDoesNotResolveToAPage (start)

Error message

SR.SelectionDoesNotResolveToAPage (start)

What it means

ArgumentException from FixedTextSelectionProcessor.GetSelectedNodes: the selection's start point cannot be resolved to a fixed-document page (GetPointerPage left the page number at its int.MinValue sentinel), so the start of the selection does not map to any FixedPage.

Solutions

  1. Verify the selection lies within a fixed document (FlowDocument selections are not supported by this processor) before converting it to nodes
  2. Trim the selection to a segment whose start resolves to a page, or re-acquire the selection after pagination completes
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Annotations/Anchoring/FixedTextSelectionProcessor.cs:99 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/95c6986c5fd0f155. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Annotations/Anchoring/FixedTextSelectionProcessor.cs:99

        /// <exception cref="ArgumentNullException">selection is null</exception>
        /// <exception cref="ArgumentException">selection is of wrong type</exception>
        /// <exception cref="ArgumentException">selection start or end point can not be resolved to a page</exception>
        public override IList<DependencyObject> GetSelectedNodes(Object selection)
        {
            IList<TextSegment> textSegments = CheckSelection(selection);

            IList<DependencyObject> pageEl = new List<DependencyObject>();

            Point start;
            Point end;
            foreach (TextSegment segment in textSegments)
            {
                int startPage = int.MinValue;
                ITextPointer startPointer = segment.Start.CreatePointer(LogicalDirection.Forward);
                TextSelectionHelper.GetPointerPage(startPointer, out startPage);
                start = TextSelectionHelper.GetPointForPointer(startPointer);
                if (startPage == int.MinValue)
                    throw new ArgumentException(SR.Format(SR.SelectionDoesNotResolveToAPage, "start"), nameof(selection));

                int endPage = int.MinValue;
                ITextPointer endPointer = segment.End.CreatePointer(LogicalDirection.Backward);
                TextSelectionHelper.GetPointerPage(endPointer, out endPage);
                end = TextSelectionHelper.GetPointForPointer(endPointer);
                if (endPage == int.MinValue)
                    throw new ArgumentException(SR.Format(SR.SelectionDoesNotResolveToAPage, "end"), nameof(selection));

                int firstPage = pageEl.Count;
                int numOfPages = endPage - startPage;

                Debug.Assert(numOfPages >= 0, "start page number is bigger than the end page number");

                // If the first page of this segment already has an FPP, then use that one for an additional segment
                int i = 0;

                if (pageEl.Count > 0 && ((FixedPageProxy)pageEl[pageEl.Count - 1]).Page == startPage)
                {

View on GitHub (pinned to 81131a70a4)