我已将Blazor Web程序集应用程序更新为最新的3.2.0预览版2,但无法在App.razor中解决此错误
错误非常简单,找不到NewLayout1。它存在,它继承了LayoutComponentBase,但由于某种原因App.razor看不到它。
该如何解决?
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(NewLayout1)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(NewLayout1)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
找不到类型或名称空间名称“ NewLayout1”(您是 缺少using指令或程序集引用?)
无法将lambda表达式转换为预期的委托类型,因为 块中的某些返回类型不是隐式可转换的 返回委托返回类型\ Debug \ netstandard2.1 \ Razor \ App.razor.g.cs
__builder.AddAttribute(2, "Found", (Microsoft.AspNetCore.Components.RenderFragment<Microsoft.AspNetCore.Components.RouteData>)((routeData) => (__builder2) => {
__builder2.AddMarkupContent(3, "\r\n ");
__builder2.OpenComponent<Microsoft.AspNetCore.Components.RouteView>(4);
__builder2.AddAttribute(5, "RouteData", Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<Microsoft.AspNetCore.Components.RouteData>(
#nullable restore
#line 3 "C:\Users\Source\Repos\Admin.Blazor.Client\Admin.UI\Client\App.razor"
routeData
#line default
#line hidden
#nullable disable
));
__builder2.AddAttribute(6, "DefaultLayout", Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<System.Type>(
#nullable restore
#line 3 "C:\Users\\Source\Repos\Admin.Blazor.Client\Admin.UI\Client\App.razor"
typeof(NewLayout1)
#line default
#line hidden
#nullable disable
));
__builder2.CloseComponent();
__builder2.AddMarkupContent(7, "\r\n ");
}
));
答案 0 :(得分:2)
NewLayout1
的命名空间是什么?
尝试在@namespace Admin.UI
组件中设置NewLayout1
。
并确保在@using Admin.UI
中设置了_Imports.razor