{"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/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Components/src/RenderTree/Renderer.cs#L1356-L1392","documentation":"ResolveComponentForRenderMode is a virtual method on Renderer whose base implementation throws NotSupportedException. Renderer subclasses (such as those in the Server and WebAssembly hosts) override it to support specific render modes. When a component declares or is assigned a render mode (via @rendermode or [RenderMode]) that the current platform's renderer does not support, the base method throws. This is the mechanism that prevents, for example, trying to render a WebAssembly component in a pure static SSR context.","triggerScenarios":"Applying a render mode (InteractiveServer, InteractiveWebAssembly, InteractiveAuto) to a component when the active renderer does not support it. For example, using InteractiveWebAssembly in a project that doesn't have WebAssembly services configured, or using InteractiveServer in a static SSR-only Blazor Web App. Also triggered if the renderer subclass's override logic doesn't handle the specific render mode value.","commonSituations":"Adding @rendermode InteractiveWebAssembly without configuring WebAssembly interactivity in Program.cs; using InteractiveServer in a component rendered during static SSR; version mismatch where a render mode constant exists but the host services aren't registered; misconfigured Blazor Web App that mixes global vs per-page interactivity incorrectly.","solutions":["Ensure the render mode you apply (@rendermode) matches a platform that is configured. In Program.cs, call builder.Services.AddRazorComponents().AddInteractiveServerComponents() and/or AddInteractiveWebAssemblyComponents().","Verify that the .Client project exists and is referenced if using InteractiveWebAssembly or InteractiveAuto.","If using per-page interactivity, make sure each page's @rendermode matches an enabled platform.","If you need static SSR only, remove all @rendermode directives from the component or page.","Update to a compatible Blazor version if a render mode type is not recognized."],"exampleFix":"// before (Program.cs - missing WebAssembly services)\nbuilder.Services.AddRazorComponents()\n    .AddInteractiveServerComponents();\n// but razor has: @rendermode InteractiveWebAssembly\n\n// after\nbuilder.Services.AddRazorComponents()\n    .AddInteractiveServerComponents()\n    .AddInteractiveWebAssemblyComponents();\nbuilder.Services.AddRazorComponents()\n    .AddInteractiveWebAssemblyComponents(renderMode => { }); // ensure client project referenced","handlingStrategy":"validation","validationCode":"// Check configured render modes before applying @rendermode\nstatic bool IsRenderModeSupported(IServiceCollection services, IComponentRenderMode mode)\n{\n    // Check that the corresponding Add*Components() was called\n    // This is a heuristic; actual support is determined by the renderer\n    return mode is InteractiveServerRenderMode\n        || mode is InteractiveWebAssemblyRenderMode\n        || mode is InteractiveAutoRenderMode;\n}\n// Ensure in Program.cs:\n// builder.Services.AddRazorComponents()\n//     .AddInteractiveServerComponents()\n//     .AddInteractiveWebAssemblyComponents();","typeGuard":"null // No type guard; render mode support is runtime/config-dependent","tryCatchPattern":"try\n{\n    // Render component with render mode\n}\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"render mode\"))\n{\n    // Fallback to static SSR or log configuration error\n    logger.LogError(ex, \"Render mode not supported. Check Program.cs services.\");\n}","preventionTips":["Register all required render mode services in Program.cs (AddInteractiveServerComponents, AddInteractiveWebAssemblyComponents).","Ensure the .Client project is referenced when using WebAssembly or Auto render modes.","Write an integration test that verifies each render mode works end-to-end.","Document which render modes are enabled in the app's configuration."],"tags":["blazor","rendermode","renderer","platform","configuration","interop"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}