Search code examples
xamlmaui-blazor

Maui Blazor Error XFC0000 Cannot resolve type "clr-namespace:[Project name]:Main


This error suddenly came into my project and prevents me to build it. Erp is the name of the project.
I am building same project in other machine with no problem, and I can't see any difference.
Nuget packages are all installed correctly.
Error complains from line 10 of 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:Erp"
             x:Class="Erp.MainPage"
             BackgroundColor="{DynamicResource PageBackgroundColor}">

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

</ContentPage>

Main.razor also looks ok:

<Router AppAssembly="@typeof(Main).Assembly">
    <Found Context="routeData">
        <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
        <FocusOnNavigate RouteData="@routeData" Selector="h1" />
    </Found>
    <NotFound>
        <LayoutView Layout="@typeof(MainLayout)">
            <p role="alert">Sorry, there's nothing at this address.</p>
        </LayoutView>
    </NotFound>
</Router>

Solution

  • Finally discovered a bug, I left a @ character alone inside a div and this resulted in error XFC0000:

        <div class="Errs">
            <i class="fa-solid fa-triangle-exclamation"></i>
            @
        </div>