【问题标题】:Maui Blazor Error XFC0000 Cannot resolve type "clr-namespace:[Project name]:MainMaui Blazor 错误 XFC0000 无法解析类型 \"clr-namespace:[项目名称]:Main
【发布时间】:2022-11-24 13:03:01
【问题描述】:

这个错误突然进入我的项目并阻止我构建它。 Erp 是项目的名称。
我在其他机器上构建相同的项目没有问题,我看不出有什么区别。
Nuget 包都已正确安装。
MainPage.xaml 的第 10 行报错:

<?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 看起来也不错:

<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>

【问题讨论】:

    标签: xaml maui-blazor


    【解决方案1】:

    终于发现了一个错误,我在 div 中单独留下了一个 @ 字符,这导致了错误 XFC0000:

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

    【讨论】:

      【解决方案2】:

      解决了 如果从以前创建的项目中复制代码,请在使用关键字后检查应用程序名称,并对路由进行良好编码。

      【讨论】:

        猜你喜欢
        • 2022-12-06
        • 2021-06-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-06
        • 1970-01-01
        • 2016-11-29
        • 1970-01-01
        相关资源
        最近更新 更多