dotnet/aspnetcore · error · InvalidOperationException
{nameof(DynamicComponent)} does not accept a parameter with
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
Thrown by DynamicComponent.SetParametersAsync when it receives a parameter whose name is not 'Type' or 'Parameters'. DynamicComponent deliberately does not use CaptureUnmatchedValues, so arbitrary parameters are rejected — to pass values to the dynamically-rendered child component you must use the Parameters dictionary. The rejection is at DynamicComponent.cs:77-81.
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 294cab2f9b)
Solutions
- Pass child parameters via the Parameters dictionary: <DynamicComponent Type="@t" Parameters="@params" /> where params is a Dictionary<string,object>.
- Remove any direct attributes that aren't Type or Parameters.
Example fix
// before
<DynamicComponent Type="@componentType" Title="@title" OnClick="@handler" />
// after
<DynamicComponent Type="@componentType" Parameters="@_params" />
@code {
private Dictionary<string, object> _params = new()
{
["Title"] = title,
["OnClick"] = EventCallback.Create(this, handler)
};
} Defensive patterns
Strategy: validation
Validate before calling
var valid = new[] { "Type", "Parameters" };
foreach (var p in parameters)
if (!valid.Contains(p.Name))
throw new InvalidOperationException($"Use Parameters dictionary, not '{p.Name}'."); Prevention
- Always pass child component values via the Parameters dictionary on DynamicComponent.
- Never add direct attributes other than Type or Parameters.
When it happens
Trigger: Writing <DynamicComponent SomeProp="x"> instead of passing SomeProp via the Parameters dictionary; trying to set component parameters directly on DynamicComponent in markup.
Common situations: Assuming DynamicComponent forwards unmatched attributes to the child; copy-pasting a usage that worked with a concrete component but applying it to DynamicComponent.
Related errors
- {nameof(DynamicComponent)} requires a non-null value for the
- The component '{nameof(CascadingValue<TValue>)}' does not ac
- Missing required parameter '{nameof(Value)}' for component '
- There is no file with ID ${fileId}. The file list may have c
- Invalid sequence number or identifier '${sequenceOrIdentifie
AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06).
Data as JSON: /api/errors/12a3be476a93ae64.
Report an issue: GitHub.