{"record":{"id":"29a03295b5c80fc5","repo":"dotnet/aspnetcore","slug":"cannot-supply-a-component-of-type-componenttype","errorCode":null,"errorMessage":"Cannot supply a component of type '{componentType}' because the current platform does not support the render mode '{renderMode}'.","messagePattern":"Cannot supply a component of type '(.+?)' because the current platform does not support the render mode '(.+?)'\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/RenderTree/Renderer.cs","lineNumber":1374,"sourceCode":"    /// Determines how to handle an <see cref=\"IComponentRenderMode\"/> when obtaining a component instance.\n    /// This is only called when a render mode is specified either at the call site or on the component type.\n    ///\n    /// Subclasses may override this method to return a component of a different type, or throw, depending on whether the renderer\n    /// supports the render mode and how it implements that support.\n    /// </summary>\n    /// <param name=\"componentType\">The type of component that was requested.</param>\n    /// <param name=\"parentComponentId\">The parent component ID, or null if it is a root component.</param>\n    /// <param name=\"componentActivator\">An <see cref=\"IComponentActivator\"/> that should be used when instantiating component objects.</param>\n    /// <param name=\"renderMode\">The <see cref=\"IComponentRenderMode\"/> declared on <paramref name=\"componentType\"/> or at the call site (for example, by the parent component).</param>\n    /// <returns>An <see cref=\"IComponent\"/> instance.</returns>\n    protected internal virtual IComponent ResolveComponentForRenderMode(\n        [DynamicallyAccessedMembers(Component)] Type componentType,\n        int? parentComponentId,\n        IComponentActivator componentActivator,\n        IComponentRenderMode renderMode)\n    {\n        // Nothing is supported by default. Subclasses must override this to opt into supporting specific render modes.\n        throw new NotSupportedException($\"Cannot supply a component of type '{componentType}' because the current platform does not support the render mode '{renderMode}'.\");\n    }\n\n    /// <summary>\n    /// Releases all resources currently used by this <see cref=\"Renderer\"/> instance.\n    /// </summary>\n    public void Dispose()\n    {\n        Dispose(disposing: true);\n    }\n\n    /// <inheritdoc />\n    public async ValueTask DisposeAsync()\n    {\n        lock (_lockObject)\n        {\n            if (_rendererIsDisposed)\n            {\n                return;","sourceCodeStart":1356,"sourceCodeEnd":1392,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/RenderTree/Renderer.cs#L1356-L1392","documentation":"ResolveComponentForRenderMode was asked to instantiate a component whose declared IComponentRenderMode is not supported by the current Renderer subclass. The base Renderer throws NotSupportedException by default; subclasses (HtmlRenderer, WebAssemblyRenderer, etc.) override it to opt into specific modes. So the throw means no renderer in the host platform accepted the requested mode.","triggerScenarios":"A component declares @rendermode or a caller specifies RenderMode.ServerInteractivePrerendered but the running host is a static/server-only renderer (HtmlServerPrerendered with no interactivity, or a unit-test HtmlRenderer). Prerendering on a host that doesn't have Server/WebAssembly interactivity configured. Mixing render modes unsupported by the project's interactivity config in .NET 8+.","commonSituations":"Adding @rendermode InteractiveServer to a component in a project where `builder.Services.AddRazorComponents().AddInteractiveServerComponents()` was never called. Running a Blazor Web App under a host that only does static SSR. Migrating a Server-only app and forgetting to register interactivity. Unit tests using a plain HtmlRenderer that doesn't override ResolveComponentForRenderMode.","solutions":["Register the matching interactivity services in Program.cs: AddInteractiveServerComponents() and/or AddInteractiveWebAssemblyComponents().","Confirm the component's @rendermode matches a mode the host actually supports (Server vs WebAssembly vs None).","For tests, subclass HtmlRenderer and override ResolveComponentForRenderMode to support the modes under test.","Check that the project references the right interactivity package (e.g. Microsoft.AspNetCore.Components.Server)."],"exampleFix":"// before\nbuilder.Services.AddRazorComponents();\n\n// after\nbuilder.Services.AddRazorComponents()\n    .AddInteractiveServerComponents()\n    .AddInteractiveWebAssemblyComponents();","handlingStrategy":"validation","validationCode":"// At startup, verify the host supports the modes your components declare\nvar supported = builder.Services.Where(d => d.ServiceType == typeof(IComponentRenderMode)).ToList();\n// and ensure AddInteractive{Server,WebAssembly}Components() are called for the modes used","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register AddInteractiveServerComponents()/AddInteractiveWebAssemblyComponents() in Program.cs.","Keep a project convention: components declare @rendermode only when the host supports it.","For tests, override ResolveComponentForRenderMode on a custom HtmlRenderer subclass."],"tags":["blazor","render-mode","interactivity","host-configuration","di"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}