.netblazormaui.net-8.0hybrid

.NET MAUI Blazor Hybrid - cannot resolve clr-namespace for Components.Routes


Created a new.net8.0 MAUI Blazor Hybrid App (New solution). Built solution and got the error:

XFC0000 Cannot resolve type "clr-namespace:MauiApp1:Components.Routes"

Code is all stock but here it is.

MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:MauiApp1"
             x:Class="MauiApp1.MainPage"
             BackgroundColor="{DynamicResource PageBackgroundColor}">

    <BlazorWebView x:Name="blazorWebView" HostPage="wwwroot/index.html">
        <BlazorWebView.RootComponents>
            <RootComponent Selector="#app" ComponentType="{x:Type local:Components.Routes}" />
        </BlazorWebView.RootComponents>
    </BlazorWebView>

</ContentPage>

Routes.Razor

<Router AppAssembly="@typeof(MauiProgram).Assembly">
    <Found Context="routeData">
        <RouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" />
        <FocusOnNavigate RouteData="@routeData" Selector="h1" />
    </Found>
</Router>

Anyone have any idea what's going on?


Solution

  • I had the same error on a completely fresh MAUI Blazor Hybrid App in Visual Studio. There must have been a problem with this introduced in .NET SDK 8.0.2.

    I downgraded my .NET SDK install to v8.0.1 and the problem was fixed for me.