dotnet/wpf · error · ArgumentException

SR.InvalidSubTreeProcessor

Error message

SR.InvalidSubTreeProcessor

What it means

LocatorManager.GetSubTreeProcessor looks up the processor registered for a given processor string (locator base Id). If the key exists but holds no processor it throws ArgumentException(SR.InvalidSubTreeProcessor, processorString) — the annotation references a subtree processor that is not registered/known to this LocatorManager.

Solutions

  1. Use processor Ids registered with the LocatorManager (e.g. DataIdProcessor.Id) when authoring locators.
  2. Register any custom subtree processor before processing annotations.
  3. Validate stored annotations' processor strings against the known set at load time.

Example fix

// before
locator.Add(new ContentLocatorPart(new XmlQualifiedName("CustomPart", "http://my/ns"))); // unknown processor string
// after
locator.Add(new ContentLocatorPart(FixedTextSelectionProcessor.FixedTextElementName)); // known/registered processor
Defensive patterns

Strategy: try-catch

Validate before calling

if (!_knownProcessorIds.Contains(processorString)) throw new InvalidOperationException($"Processor '{processorString}' not registered");

Try / catch

try { var p = manager.GetSubTreeProcessor(locatorBase); } catch (ArgumentException ex) { /* unknown processor string — fall back to DataIdProcessor or skip */ }

Prevention

When it happens

Trigger: Resolving annotations whose ContentLocatorBase lists a processor Id (e.g. 'ProcessId' attribute) that is not registered in LocatorManager._subtreeProcessors, or after a registration was cleared.

Common situations: Loading annotation stores produced by other apps/custom processors; namespace/type renames across .NET versions; constructing ContentLocator with a ProcessId that was never registered via AddSubTreeProcessor-equivalent path.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Annotations/Anchoring/LocatorManager.cs:133

        /// on this node, or an instance of the DataIdProcessor if none is specified</returns>
        /// <exception cref="ArgumentNullException">node is null</exception>
        public SubTreeProcessor GetSubTreeProcessor(DependencyObject node)
        {
            VerifyAccess();

            ArgumentNullException.ThrowIfNull(node);

            // This property should contain one or more (comma-delimited) 
            // registered string IDs for subtree processors.
            string processorString = node.GetValue(SubTreeProcessorIdProperty) as string;
            if (!String.IsNullOrEmpty(processorString))
            {
                SubTreeProcessor processor = (SubTreeProcessor)_subtreeProcessors[processorString];

                if (processor != null)
                    return processor;
                else
                    throw new ArgumentException(SR.Format(SR.InvalidSubTreeProcessor, processorString));
            }
            else
            {
                return _subtreeProcessors[DataIdProcessor.Id] as SubTreeProcessor;
            }
        }

        /// <summary>
        ///     Returns the subtree processor registered to handle the locator 
        ///     part's type.  If none is registered, null is returned.
        /// </summary>
        /// <param name="locatorPart">locator part for which a subtree processor
        /// is being retreived</param>
        /// <returns>a subtree processor registered to handle the locator part's
        /// type; null if no such processor is registred</returns>
        /// <exception cref="ArgumentNullException">locatorPart is null</exception>
        public SubTreeProcessor GetSubTreeProcessorForLocatorPart(ContentLocatorPart locatorPart)
        {

View on GitHub (pinned to 81131a70a4)