XAML 错误XFC 0000无法解析类型“clr-namespace:[项目名称]:Main

nbewdwxp  于 2022-12-07  发布在  其他
关注(0)|答案(2)|浏览(327)

这个错误突然出现在我的项目中,阻止了我构建它。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.剃刀看起来也不错:

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

fae0ux8s1#

最后发现了一个错误,我在div中单独留下了一个@字符,这导致了错误XFC 0000:

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

kuarbcqp2#

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

相关问题