dotnet/aspnetcore · error · InvalidOperationException

Object of type '{targetType.FullName}' has a property matchi

Error message

Object of type '{targetType.FullName}' has a property matching the name '{parameterName}', but it does not have [Parameter], [CascadingParameter], or any other parameter-supplying attribute.

What it means

Thrown by ComponentProperties.ThrowForUnknownIncomingParameterName when an incoming parameter name matches a property on the component, but that property lacks [Parameter], [CascadingParameter], or any other parameter-supplying attribute. The property exists but is not exposed as a parameter.

Source

Thrown at src/Components/Components/src/Reflection/ComponentProperties.cs:202

        }
    }

    internal static IEnumerable<PropertyInfo> GetCandidateBindableProperties([DynamicallyAccessedMembers(Component)] Type targetType)
        => MemberAssignment.GetPropertiesIncludingInherited(targetType, BindablePropertyFlags);

    [DoesNotReturn]
    private static void ThrowForUnknownIncomingParameterName([DynamicallyAccessedMembers(Component)] Type targetType,
        string parameterName)
    {
        // We know we're going to throw by this stage, so it doesn't matter that the following
        // reflection code will be slow. We're just trying to help developers see what they did wrong.
        var propertyInfo = targetType.GetProperty(parameterName, BindablePropertyFlags);
        if (propertyInfo != null)
        {
            if (!propertyInfo.IsDefined(typeof(ParameterAttribute)) &&
                !propertyInfo.GetCustomAttributes().OfType<CascadingParameterAttributeBase>().Any())
            {
                throw new InvalidOperationException(
                    $"Object of type '{targetType.FullName}' has a property matching the name '{parameterName}', " +
                    $"but it does not have [Parameter], [CascadingParameter], or any other parameter-supplying attribute.");
            }
            else
            {
                // This should not happen
                throw new InvalidOperationException(
                    $"No writer was cached for the property '{propertyInfo.Name}' on type '{targetType.FullName}'.");
            }
        }
        else
        {
            throw new InvalidOperationException(
                $"Object of type '{targetType.FullName}' does not have a property " +
                $"matching the name '{parameterName}'.");
        }
    }

View on GitHub (pinned to 294cab2f9b)

Solutions

  1. Add [Parameter] to the property if it should be settable from markup.
  2. If the property is not meant to be a parameter, remove that attribute from the markup - non-parameter properties cannot be set declaratively.
  3. Check the component's source/docs to confirm which properties are real parameters.

Example fix

// before
// Child.razor.cs
public string Title { get; set; } // no [Parameter]
<Child Title="Hi" />

// after
[Parameter] public string Title { get; set; }
Defensive patterns

Strategy: validation

Validate before calling

// Confirm a property is a real parameter before passing it in markup/tests.
static bool IsParameter(Type componentType, string propertyName)
{
    var p = componentType.GetProperty(propertyName,
        BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
    return p?.GetCustomAttribute<ParameterAttribute>() is not null
        || p?.GetCustomAttributes().OfType<CascadingParameterAttributeBase>().Any() == true;
}

Type guard

static bool HasParameterAttribute(PropertyInfo p)
    => p.GetCustomAttribute<ParameterAttribute>() is not null
       || p.GetCustomAttributes().OfType<CascadingParameterAttributeBase>().Any();

Prevention

When it happens

Trigger: Passing an attribute/parameter in markup to a child component where the target property is a plain public property not decorated with a parameter attribute.

Common situations: Forgetting the [Parameter] attribute; setting a property meant to be internal-only; a name collision with a non-parameter public property; an upgraded component library that removed an attribute.

Related errors


AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06). Data as JSON: /api/errors/656e88cc02ea6292. Report an issue: GitHub.