user3656651
user3656651

Reputation: 822

Blazor application shows error in console when Auto mode is used

I used Visual Studio latest preview with .NET8 RC1 to build a new Blazor App that allows Client and Server interactive components. By default, the app has its default rendering mode which I think is SSR.

In order to switch to the Auto mode, I used the following code as suggested by Microsoft (https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-8.0)

So I have this:

    <Routes @rendermode="@RenderMode.Auto"/>

in my App.razor file.

Although the app runs, I see this error in the browser console:

Uncaught (in promise) Error: System.InvalidOperationException: Root component type 'BlazorApp9.Components.Routes' could not be found in the assembly 'BlazorApp9'.
   at Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer.<UpdateRootComponents>g__AddRootComponent|8_0(RootComponentOperation operation)
   at Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer.UpdateRootComponents(String operationsJson)
   at Microsoft.AspNetCore.Components.RenderTree.WebRenderer.WebRendererInteropMethods.UpdateRootComponents(String operationsJson)
   at 

If I use RenderMode.Server, I dont see this error.

I have not changed any code to the template provided by Visual Studio.

Any ideas?

Upvotes: 9

Views: 4875

Answers (1)

Mister Magoo
Mister Magoo

Reputation: 8994

Any interactive components (which is what you are making Routes by setting its RenderMode to Auto) must be moved to the webassembly/client project in RC1.

This is required because Routes must now be built in WASM and sent to the browser as part of the webassembly bits.

Upvotes: 10

Related Questions