Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Unable to cast object of type 'Server.Circuits.RemoteNavigationManager' to type 'WebView.Services.WebViewNavigationManager'

$
0
0

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?

EDIT:

Index.razor:

@page "/"<PageTitle>Main Page</PageTitle>//plain html

MainPage.xaml, App.xaml, Routes.razor is the same as it was on creating from template.MauiProgram contains registrations, including those I have written above.


Viewing all articles
Browse latest Browse all 4839

Trending Articles