{"record":{"id":"514796de0b3d7cd3","repo":"dotnet/aspnetcore","slug":"the-component-type-componenttype-has-a-fixed-r","errorCode":null,"errorMessage":"The component type '{componentType}' has a fixed rendermode of '{componentTypeRenderMode}', so it is not valid to specify any rendermode when using this component.","messagePattern":"The component type '(.+?)' has a fixed rendermode of '(.+?)', so it is not valid to specify any rendermode when using this component\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/ComponentFactory.cs","lineNumber":74,"sourceCode":"\n    public IComponent InstantiateComponent(IServiceProvider serviceProvider, [DynamicallyAccessedMembers(Component)] Type componentType, IComponentRenderMode? callerSpecifiedRenderMode, int? parentComponentId)\n    {\n        var componentTypeRenderMode = GetComponentTypeRenderMode(componentType);\n        IComponent component;\n\n        if (componentTypeRenderMode is null && callerSpecifiedRenderMode is null)\n        {\n            // Typical case where no rendermode is specified in either location. We don't call ResolveComponentForRenderMode in this case.\n            component = _componentActivator.CreateInstance(componentType);\n        }\n        else\n        {\n            // At least one rendermode is specified. We require that it's exactly one, and use ResolveComponentForRenderMode with it.\n            var effectiveRenderMode = callerSpecifiedRenderMode is null\n                ? componentTypeRenderMode!\n                : componentTypeRenderMode is null\n                    ? callerSpecifiedRenderMode\n                    : 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.\");\n            component = _renderer.ResolveComponentForRenderMode(componentType, parentComponentId, _componentActivator, effectiveRenderMode);\n        }\n\n        if (component is null)\n        {\n            // The default activator/resolver will never do this, but an externally-supplied one might\n            throw new InvalidOperationException($\"The component activator returned a null value for a component of type {componentType.FullName}.\");\n        }\n\n        if (!_propertyInjectionDisabled)\n        {\n            PerformPropertyInjection(serviceProvider, component);\n        }\n\n        return component;\n    }\n\n    private void PerformPropertyInjection(IServiceProvider serviceProvider, IComponent instance)","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/ComponentFactory.cs#L56-L92","documentation":"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.","triggerScenarios":"<MyComponent RenderMode=\"InteractiveServer\" /> where MyComponent is decorated with [RenderModeInteractiveServer] (or any fixed RenderMode attribute).","commonSituations":"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.","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."],"exampleFix":"// before\n// MyComponent.razor.cs: [RenderModeInteractiveServer]\n<MyComponent RenderMode=\"InteractiveServer\" />\n// after\n<MyComponent />","handlingStrategy":"validation","validationCode":"// Ensure a component is not decorated with a fixed RenderMode attribute when callers also pass a render mode.\nvar hasFixed = componentType.GetCustomAttributes(true).Any(a => a is IComponentRenderMode);\nif (hasFixed) { /* do not pass RenderMode at call site */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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)."],"tags":["blazor","render-mode","interactive","component-factory"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}