dotnet/aspnetcore · error · InvalidOperationException

Object of type ' ' has a property matching the name ' '…

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

ThrowForUnknownIncomingParameterName fires when the parameter-binding cache cannot find a writer for an incoming parameter name, but reflection then locates a property with that name on the component type. If that property lacks both [Parameter] (or ParameterAttribute) and any CascadingParameterAttributeBase, the framework cannot route a value to it; Blazor parameters must be explicitly marked. The error tells the developer which attribute is missing.

Solutions

  1. Add [Parameter] to the property that should receive the value.
  2. If the property is meant to receive a cascading value, add [CascadingParameter] (or a derived attribute) and pass it as a cascading value, not a direct parameter.
  3. If the property is not intended as a parameter, rename or remove the incoming parameter from markup so it does not collide.

Example fix

// before
// Counter.razor.cs
public int Count { get; set; }
// usage
<Counter Count="5" />

// after
[Parameter]
public int Count { get; set; }
Defensive patterns

Strategy: type-guard

Type guard

static bool IsBlazorParameter(PropertyInfo p)
    => p.GetCustomAttribute<ParameterAttribute>() != null
       || p.GetCustomAttributes().OfType<CascadingParameterAttributeBase>().Any();

// Before binding, ensure the target property is annotated:
if (!IsBlazorParameter(typeof(MyComponent).GetProperty("Foo")!))
    throw new InvalidOperationException("Foo is not a parameter.");

Prevention

When it happens

Trigger: Passing a parameter in markup or via RenderTreeBuilder to a property that exists on the component but is not annotated with [Parameter] or [CascadingParameter]. Forgetting the [Parameter] attribute on a property intended to receive values. Typing a parameter name that coincidentally matches a non-parameter public property.

Common situations: Creating a component, adding a public property meant to be a parameter, but forgetting [Parameter]. Renaming an actual parameter and leaving a stale property without the attribute. Passing arbitrary attributes that collide with helper/internal property names.

Related errors


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

Appendix: 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 3600ca084e)