dotnet/aspnetcore · error · InvalidOperationException

does not accept a parameter with the name ' '. To pass…

Error message

{nameof(DynamicComponent)} does not accept a parameter with the name '{entry.Name}'. To pass parameters to the dynamically-rendered component, use the '{nameof(Parameters)}' parameter.

What it means

DynamicComponent only accepts two direct parameters: 'Type' and 'Parameters'. Any other attribute is rejected with InvalidOperationException. To pass values to the rendered component, use the Parameters dictionary rather than top-level attributes.

Solutions

  1. Move extra attributes into the Parameters dictionary.
  2. Build a Dictionary<string, object?> with the inner component's parameters.
  3. Keep only Type and Parameters as direct attributes on DynamicComponent.

Example fix

// before
<DynamicComponent Type="@compType" Count="@n" Label="@lbl" />
// after
<DynamicComponent Type="@compType" Parameters="@(new Dictionary<string,object?>{ ["Count"]=n, ["Label"]=lbl })" />
Defensive patterns

Strategy: validation

Validate before calling

// Only pass Type and Parameters directly; route everything else through Parameters.
var dynParams = new Dictionary<string, object?> { ["Count"] = n };
<DynamicComponent Type="@t" Parameters="@dynParams" />

Prevention

When it happens

Trigger: <DynamicComponent Type="@t" SomeProp="x" /> instead of routing SomeProp through the Parameters dictionary.

Common situations: Confusing DynamicComponent with a regular component, copy-pasting attributes from a typed usage, or assuming DynamicComponent forwards arbitrary attributes.

Related errors


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

Appendix: source

Thrown at src/Components/Components/src/DynamicComponent.cs:79

    /// <inheritdoc />
    [UnconditionalSuppressMessage("Trimming", "IL2072", Justification = "We expect that types used with DynamicComponent will be defined in assemblies that don't get trimmed.")]
    public Task SetParametersAsync(ParameterView parameters)
    {
        // This manual parameter assignment logic will be marginally faster than calling
        // ComponentProperties.SetProperties.
        foreach (var entry in parameters)
        {
            if (entry.Name.Equals(nameof(Type), StringComparison.OrdinalIgnoreCase))
            {
                Type = (Type)entry.Value;
            }
            else if (entry.Name.Equals(nameof(Parameters), StringComparison.OrdinalIgnoreCase))
            {
                Parameters = (IDictionary<string, object>)entry.Value;
            }
            else
            {
                throw new InvalidOperationException(
                    $"{nameof(DynamicComponent)} does not accept a parameter with the name '{entry.Name}'. To pass parameters to the dynamically-rendered component, use the '{nameof(Parameters)}' parameter.");
            }
        }

        if (Type is null)
        {
            throw new InvalidOperationException($"{nameof(DynamicComponent)} requires a non-null value for the parameter {nameof(Type)}.");
        }

        _renderHandle.Render(_cachedRenderFragment);
        return Task.CompletedTask;
    }

    void Render(RenderTreeBuilder builder)
    {
        builder.OpenComponent(0, Type);

        if (Parameters != null)

View on GitHub (pinned to 3600ca084e)