{"record":{"id":"9a871f983cf7b936","repo":"dotnet/wpf","slug":"sr-selectiondoesnotresolvetoapage-end","errorCode":null,"errorMessage":"SR.SelectionDoesNotResolveToAPage (end)","messagePattern":"SR\\.SelectionDoesNotResolveToAPage \\(end\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Annotations/Anchoring/FixedTextSelectionProcessor.cs","lineNumber":106,"sourceCode":"            IList<DependencyObject> pageEl = new List<DependencyObject>();\n\n            Point start;\n            Point end;\n            foreach (TextSegment segment in textSegments)\n            {\n                int startPage = int.MinValue;\n                ITextPointer startPointer = segment.Start.CreatePointer(LogicalDirection.Forward);\n                TextSelectionHelper.GetPointerPage(startPointer, out startPage);\n                start = TextSelectionHelper.GetPointForPointer(startPointer);\n                if (startPage == int.MinValue)\n                    throw new ArgumentException(SR.Format(SR.SelectionDoesNotResolveToAPage, \"start\"), nameof(selection));\n\n                int endPage = int.MinValue;\n                ITextPointer endPointer = segment.End.CreatePointer(LogicalDirection.Backward);\n                TextSelectionHelper.GetPointerPage(endPointer, out endPage);\n                end = TextSelectionHelper.GetPointForPointer(endPointer);\n                if (endPage == int.MinValue)\n                    throw new ArgumentException(SR.Format(SR.SelectionDoesNotResolveToAPage, \"end\"), nameof(selection));\n\n                int firstPage = pageEl.Count;\n                int numOfPages = endPage - startPage;\n\n                Debug.Assert(numOfPages >= 0, \"start page number is bigger than the end page number\");\n\n                // If the first page of this segment already has an FPP, then use that one for an additional segment\n                int i = 0;\n\n                if (pageEl.Count > 0 && ((FixedPageProxy)pageEl[pageEl.Count - 1]).Page == startPage)\n                {\n                    firstPage--;  // use the existing one from the list as the first\n                    i++;  // make 1 fewer FPPs\n                }\n\n                for (; i <= numOfPages; i++)\n                {\n                    pageEl.Add(new FixedPageProxy(segment.Start.TextContainer.Parent, startPage + i));","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Annotations/Anchoring/FixedTextSelectionProcessor.cs#L88-L124","documentation":"ArgumentException from FixedTextSelectionProcessor.GetSelectedNodes: the selection's end point cannot be resolved to a fixed-document page (the page lookup for segment.End failed), so the end of the selection does not map to any FixedPage.","triggerScenarios":"Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Annotations/Anchoring/FixedTextSelectionProcessor.cs:106 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the selection lies within a fixed document and pagination has completed before processing","Trim the selection to a segment whose end resolves to a page"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}