dotnet/wpf · error · ArgumentException

SR.StartNodeMustBeFixedPageProxy

Error message

SR.StartNodeMustBeFixedPageProxy

What it means

ArgumentException from FixedTextSelectionProcessor.GenerateLocatorParts: the startNode passed in is not a FixedPageProxy (the object representing one page of a fixed document), so the processor cannot derive page-relative locator parts from it.

Solutions

  1. Pass a FixedPageProxy obtained from GetSelectedNodes as the startNode
  2. Check the node type before calling GenerateLocatorParts and route to the appropriate selection processor
Defensive patterns

Strategy: type-guard

When it happens

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

Appendix: source

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

        /// that lies within start node
        /// </summary>
        /// <param name="selection">the selection that is being processed. Must implement ITextRange</param>
        /// <param name="startNode">The FixedPageProxy object, representing one page of the document</param>
        /// <returns>A list containing one FixedTextRange locator part</returns>
        /// <exception cref="ArgumentNullException">startNode or selection is null</exception>
        /// <exception cref="ArgumentException">selection is of the wrong type</exception>
        public override IList<ContentLocatorPart>
            GenerateLocatorParts(Object selection, DependencyObject startNode)
        {
            ArgumentNullException.ThrowIfNull(startNode);
            ArgumentNullException.ThrowIfNull(selection);

            CheckSelection(selection);

            FixedPageProxy fp = startNode as FixedPageProxy;

            if (fp == null)
                throw new ArgumentException(SR.StartNodeMustBeFixedPageProxy, nameof(startNode));

            ContentLocatorPart part = new ContentLocatorPart(FixedTextElementName);
            if (fp.Segments.Count == 0)
            {
                part.NameValuePairs.Add(TextSelectionProcessor.CountAttribute, 1.ToString(NumberFormatInfo.InvariantInfo));
                part.NameValuePairs.Add(TextSelectionProcessor.SegmentAttribute + 0.ToString(NumberFormatInfo.InvariantInfo), ",,,");
            }
            else
            {
                part.NameValuePairs.Add(TextSelectionProcessor.CountAttribute, fp.Segments.Count.ToString(NumberFormatInfo.InvariantInfo));

                for (int i = 0; i < fp.Segments.Count; i++)
                {
                    string value = "";
                    if (!double.IsNaN(fp.Segments[i].Start.X))
                    {
                        value += fp.Segments[i].Start.X.ToString(NumberFormatInfo.InvariantInfo) + TextSelectionProcessor.Separator + fp.Segments[i].Start.Y.ToString(NumberFormatInfo.InvariantInfo);
                    }

View on GitHub (pinned to 81131a70a4)