Trying to move Blazor Web App to Hybrid result in exception on application start:
blazor.webview.js:1
Unable to cast object of type
'Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager' to type
'Microsoft.AspNetCore.Components.WebView.Services.WebViewNavigationManager'.
I’m pretty sure that problem in usage of @inject NavigationManager Navigation
at some of blazor components (pages). I registered razor components like this:
builder.Services
.AddRazorComponents()
.AddInteractiveServerComponents();
Without second part of line
builder.Services
.AddRazorComponents();
//.AddInteractiveServerComponents();
exception looks this way:
Unable to resolve service for type 'Microsoft.AspNetCore.Hosting.IWebHostEnvironment'
while attempting to activate 'Microsoft.Extensions.DependencyInjection.DefaultRazorComponentsServiceOptionsConfiguration'
Without the whole line another exception throws:
ExampleBlazorApp does not implement IComponent.
Is there an alternative to this line to register correct NavigationManager class for Hybrid Blazor App to avoid this exceptions? Any ideas?