dotnet/aspnetcore · error · InvalidOperationException
The component type ' ' has a fixed rendermode of ' ', so it…
Error message
The component type '{componentType}' has a fixed rendermode of '{componentTypeRenderMode}', so it is not valid to specify any rendermode when using this component. What it means
When a component type has a fixed render mode (via a RenderMode attribute such as [RenderModeInteractiveServer]) and the call site also specifies a render mode, the two conflict. Only one source of render mode is permitted, so ComponentFactory throws InvalidOperationException.
Solutions
- Remove the render mode from the call site since the component already declares a fixed one.
- Alternatively, remove the RenderMode attribute from the component if call-site flexibility is desired.
- Document which components have fixed render modes so callers do not override them.
Example fix
// before // MyComponent.razor.cs: [RenderModeInteractiveServer] <MyComponent RenderMode="InteractiveServer" /> // after <MyComponent />
Defensive patterns
Strategy: validation
Validate before calling
// Ensure a component is not decorated with a fixed RenderMode attribute when callers also pass a render mode.
var hasFixed = componentType.GetCustomAttributes(true).Any(a => a is IComponentRenderMode);
if (hasFixed) { /* do not pass RenderMode at call site */ } Prevention
- Document which components carry a fixed RenderMode attribute.
- Code-review call sites to ensure no RenderMode is passed for fixed-mode components.
- Prefer one source of truth for render mode (either attribute or call site, not both).
When it happens
Trigger: <MyComponent RenderMode="InteractiveServer" /> where MyComponent is decorated with [RenderModeInteractiveServer] (or any fixed RenderMode attribute).
Common situations: Adding a RenderMode attribute to a component and forgetting to drop the call-site RenderMode argument, or upgrading to .NET 8+ interactive rendering and specifying the mode in both places.
Related errors
- Cannot merge mismatching component descriptors
- Cannot supply a component of type
- componentActivator
- Only one interactive runtime may enable navigation…
- propertyActivator
AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11).
Data as JSON: /api/errors/514796de0b3d7cd3.
Report an issue: GitHub.
Appendix: source
Thrown at src/Components/Components/src/ComponentFactory.cs:74
public IComponent InstantiateComponent(IServiceProvider serviceProvider, [DynamicallyAccessedMembers(Component)] Type componentType, IComponentRenderMode? callerSpecifiedRenderMode, int? parentComponentId)
{
var componentTypeRenderMode = GetComponentTypeRenderMode(componentType);
IComponent component;
if (componentTypeRenderMode is null && callerSpecifiedRenderMode is null)
{
// Typical case where no rendermode is specified in either location. We don't call ResolveComponentForRenderMode in this case.
component = _componentActivator.CreateInstance(componentType);
}
else
{
// At least one rendermode is specified. We require that it's exactly one, and use ResolveComponentForRenderMode with it.
var effectiveRenderMode = callerSpecifiedRenderMode is null
? componentTypeRenderMode!
: componentTypeRenderMode is null
? callerSpecifiedRenderMode
: throw new InvalidOperationException($"The component type '{componentType}' has a fixed rendermode of '{componentTypeRenderMode}', so it is not valid to specify any rendermode when using this component.");
component = _renderer.ResolveComponentForRenderMode(componentType, parentComponentId, _componentActivator, effectiveRenderMode);
}
if (component is null)
{
// The default activator/resolver will never do this, but an externally-supplied one might
throw new InvalidOperationException($"The component activator returned a null value for a component of type {componentType.FullName}.");
}
if (!_propertyInjectionDisabled)
{
PerformPropertyInjection(serviceProvider, component);
}
return component;
}
private void PerformPropertyInjection(IServiceProvider serviceProvider, IComponent instance)View on GitHub (pinned to 3600ca084e)