{"record":{"id":"a77960aede29a849","repo":"dotnet/aspnetcore","slug":"dynamic-root-components-have-already-been-enabled","errorCode":null,"errorMessage":"Dynamic root components have already been enabled.","messagePattern":"Dynamic root components have already been enabled\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Components/Web.JS/src/Rendering/JSRootComponents.ts","lineNumber":129,"sourceCode":"\n      for (const jsEventCallbackWrapper of this._jsEventCallbackWrappers.values()) {\n        jsEventCallbackWrapper.dispose();\n      }\n    }\n  }\n}\n\n// Called by the framework\nexport function enableJSRootComponents(\n  rendererId: number,\n  managerInstance: DotNet.DotNetObject,\n  jsComponentParameters: JSComponentParametersByIdentifier,\n  jsComponentInitializers: JSComponentIdentifiersByInitializer\n): void {\n  if (manager && currentRendererId !== rendererId) {\n    // A different renderer type (e.g., Server vs WebAssembly) is trying to enable JS root components.\n    // This is a multi-host scenario which is not supported for dynamic root components.\n    throw new Error('Dynamic root components have already been enabled.');\n  }\n\n  // When the same renderer type re-enables (e.g., circuit restart or new circuit on same page),\n  // accept the new manager. The old manager's DotNetObjectReference is no longer valid anyway\n  // because the old circuit is gone. We don't dispose the old manager - doing so would cause\n  // JSDisconnectedException because the circuit that created it no longer exists.\n  currentRendererId = rendererId;\n  manager = managerInstance;\n  jsComponentParametersByIdentifier = jsComponentParameters;\n\n  if (!hasInitializedJsComponents) {\n    // Call the registered initializers. This is an arbitrary subset of the JS component types that are registered\n    // on the .NET side - just those of them that require some JS-side initialization (e.g., to register them\n    // as custom elements).\n    for (const [initializerIdentifier, componentIdentifiers] of Object.entries(jsComponentInitializers)) {\n      const initializerFunc = DotNet.findJSFunction(initializerIdentifier, 0) as JSComponentInitializerCallback;\n      for (const componentIdentifier of componentIdentifiers) {\n        const parameters = jsComponentParameters[componentIdentifier];","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Web.JS/src/Rendering/JSRootComponents.ts#L111-L147","documentation":"Thrown by enableJSRootComponents when a manager is already registered for a different rendererId. Dynamic JS root components are tied to a single renderer type (Server or WebAssembly); enabling them from a second, different renderer in the same page is a multi-host scenario the framework does not support.","triggerScenarios":"A single page hosting both a Blazor Server and a Blazor WebAssembly root (InteractiveAuto misconfigured, or two Blazor roots of different kinds) where both try to register JS root components.","commonSituations":"Blazor Web App with mixed/incorrect rendermode wiring causing both Server and WebAssembly renderers to initialize JS root components; manually booting a second Blazor instance of a different kind on one page.","solutions":["Use only one renderer type per page for JS dynamic root components.","Fix @rendermode configuration so a single renderer owns root components.","If you genuinely need both, split across separate pages/iframes rather than one document."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a single renderer type (Server OR WebAssembly) for JS root components per page.","Fix @rendermode wiring so one renderer owns root components.","Split multi-host needs across separate pages/iframes."],"tags":["blazor","root-components","multi-host","rendermode"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}