{"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/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Components/src/ComponentFactory.cs#L56-L92","documentation":"Thrown by ComponentFactory.InstantiateComponent when a component type has a [RenderMode] attribute (giving it a fixed render mode) AND the call site also specifies a render mode via @rendermode. The framework resolves exactly one render mode; when the type itself declares one, the caller must not supply another. The conflict is detected at ComponentFactory.cs:70-74.","triggerScenarios":"A component decorated with [RenderMode(InteractiveServer)] (or similar) is referenced with an explicit @rendermode=\"...\" in markup. The ternary at line 70-74 throws when neither side is null.","commonSituations":"Applying [RenderMode] at the component level and also setting @rendermode at the call site; library components that pin their own render mode being used with a caller-specified mode.","solutions":["Remove the @rendermode from the call site — let the component's own [RenderMode] attribute win.","Or remove the [RenderMode] attribute from the component type if callers need to choose.","Do not specify render mode in both places."],"exampleFix":"// before\n// Component definition\n[RenderMode(InteractiveServer)]\npublic class MyComponent : ComponentBase { }\n\n// Usage (conflict)\n<MyComponent @rendermode=\"InteractiveWebAssembly\" />\n\n// after — remove the caller-side mode\n<MyComponent />","handlingStrategy":"validation","validationCode":"var typeRenderMode = componentType.GetCustomAttribute<RenderModeAttribute>()?.Mode;\nif (typeRenderMode is not null && callerSpecifiedRenderMode is not null)\n    throw new InvalidOperationException(\"Component has a fixed rendermode; do not specify @rendermode at call site.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose render mode in one place: either the component attribute or the call site, never both.","Document which components are pinned to a render mode."],"tags":["blazor","rendermode","configuration"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}