I didn’t get the exact same error as you, but my setup is very similar, so here are my two cents:
Solution
│
├── MyApp // Server project. Set InteractiveWebAssembly or InteractiveAuto globally in App.razor
│
├── MyApp.Client // Contains Routes.razor
│
└── SharedRCL // Contains Counter.razor page (@page "/counter") without setting any render mode
In Routes.razor
, make sure the Router
is aware of routable components in the Razor Class Library (RCL) by adding the RCL’s assembly:
<Router AppAssembly="@typeof(Program).Assembly"
AdditionalAssemblies="new[] { typeof(Counter).Assembly }"> @* <-- This line here *@
...
</Router>
Depending on your setup, you might also need to ensure that the server knows about routable components in the RCL.
In MyApp/Program.cs
, register the same assembly when mapping Razor components:
app.MapRazorComponents<App>()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(MyApp.Client._Imports).Assembly)
.AddAdditionalAssemblies(typeof(Counter).Assembly); // <-- This line here