dotnet/aspnetcore · error · InvalidOperationException
requires a non-null value for the parameter .
Error message
{nameof(DynamicComponent)} requires a non-null value for the parameter {nameof(Type)}. What it means
DynamicComponent requires a non-null Type parameter naming the component to render. Omitting it leaves the component with nothing to render, which is rejected with InvalidOperationException.
Solutions
- Always supply a non-null Type attribute.
- Guard the DynamicComponent with @if(type is not null) so it only renders when a type is available.
- Provide a fallback/default component type.
Example fix
// before
<DynamicComponent Type="@maybeNullType" />
// after
@if(maybeNullType is not null)
{
<DynamicComponent Type="@maybeNullType" />
} Defensive patterns
Strategy: validation
Validate before calling
// Guard DynamicComponent so it only renders with a non-null Type.
@if (componentType is not null)
{
<DynamicComponent Type="@componentType" />
} Prevention
- Always supply Type, or guard the markup with @if(type is not null).
- Provide a default/fallback component type when the dynamic type is unknown.
- Avoid binding Type to expressions that can evaluate to null.
When it happens
Trigger: <DynamicComponent /> or <DynamicComponent Parameters="@p" /> without a Type, or Type bound to a variable that is null at render time.
Common situations: Type bound to a runtime-resolved value that is initially null, conditional Type that evaluates to null, or forgetting the attribute.
Related errors
- Missing required parameter
- does not accept a parameter with the name ' '. To pass…
- initialParameters must be an object, even if empty.
- Multiple properties were found on component type
- Object of type ' ' does not have a property matching the…
AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11).
Data as JSON: /api/errors/7b275ea4c39c85dc.
Report an issue: GitHub.
Appendix: source
Thrown at src/Components/Components/src/DynamicComponent.cs:86
{
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)
{
foreach (var entry in Parameters)
{
builder.AddComponentParameter(1, entry.Key, entry.Value);
}
}
View on GitHub (pinned to 3600ca084e)