dotnet/wpf · error · InvalidOperationException

SR.Format(SR.PropertyPathNoProperty, ownerType.Name…

Error message

SR.Format(SR.PropertyPathNoProperty, ownerType.Name, propertyName)

What it means

ResolvePropertyName throws this InvalidOperationException when the owner type was resolved but the requested property name does not exist on that type. WPF searched CLR properties, dependency properties, and indexed-property accessors (including IDynamicMetaObjectProvider dynamic accessors) and found none matching propertyName, so the path is unresolvable.

Solutions

  1. Correct the property-name spelling in the path string to match the actual property on ownerType
  2. Verify the property exists and is public on the type: check ownerType.GetProperty(propertyName) returns non-null
  3. If the property lives on a derived type, ensure the bound item's runtime type exposes it, or cast/adjust the path
  4. For dynamic objects, confirm the member name is provided by the TryGetMember implementation

Example fix

// before
var path = new PropertyPath("(local:Customer.FirstNmae)", ctx);
// after (typo fixed)
var path = new PropertyPath("(local:Customer.FirstName)", ctx);
Defensive patterns

Strategy: validation

Validate before calling

bool propertyExists = typeof(Customer).GetProperty("FirstName",
    System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance) != null;

Type guard

bool HasPublicProperty(object o, string name) =>
    o?.GetType().GetProperty(name, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance) != null;

Try / catch

try { var path = new PropertyPath("(local:Customer.FirstName)", ctx); }
catch (InvalidOperationException ex) when (ex.Message.Contains("has no property")) { /* correct the property name */ }

Prevention

When it happens

Trigger: Binding path like '(local:Customer.FirstNmae)' where the property is misspelled; the property was removed/renamed on the owner type; the property is private/static so no public accessor is found; a dynamic object lacking the requested member.

Common situations: Refactorings renaming model properties without updating XAML binding paths; case-sensitivity mismatches; binding to properties that only exist on a derived type while the bound item is the base type; INotifyPropertyChanged property names drifting from actual CLR property names.

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/b699123c8c2581b4. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/PropertyPath.cs:637

                {
                    accessor = TypeDescriptor.GetProperties(item)[propertyName];
                }

                // 5. PropertyInfo.
                if (accessor == null)
                {
                    accessor = GetPropertyHelper(ownerType, propertyName);
                }

                // 6. IDynamicMetaObjectProvider
                // This supports the DLR's dynamic objects
                if (accessor == null && SystemCoreHelper.IsIDynamicMetaObjectProvider(item))
                {
                    accessor = SystemCoreHelper.NewDynamicPropertyAccessor(item.GetType(), propertyName);
                }

                if (accessor == null && throwOnError)
                    throw new InvalidOperationException(SR.Format(SR.PropertyPathNoProperty, ownerType.Name, propertyName));

                return accessor;
            }

            return null;
        }

        private PropertyInfo GetPropertyHelper(Type ownerType, string propertyName)
        {
            PropertyInfo result = null;
            bool enumerateBaseClasses = false;
            bool returnIndexerProperty = false;

            try
            {
                result = ownerType.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy);
            }
            catch (AmbiguousMatchException)

View on GitHub (pinned to 81131a70a4)