mko
mko

Reputation: 7325

How do i fix Blazor webassembly 3.2.0 preview 2 update issue in app.razor?

I have updated my Blazor web assembly app to the latest 3.2.0 preview 2 and I cannot resolve this error in App.razor

Error is pretty straightforward, NewLayout1 cannot be found. It exists, it inherits LayoutComponentBase but for some reason App.razor doesn't see it.

What can I do to fix this?

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

The type or namespace name 'NewLayout1' could not be found (are you missing a using directive or an assembly reference?)

Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type\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    ");
            }
            ));

Upvotes: 1

Views: 309

Answers (1)

tbdrz
tbdrz

Reputation: 2190

What is the namespace of NewLayout1 ?

Try setting@namespace Admin.UI in your NewLayout1 component.

And make sure @using Admin.UI is set in _Imports.razor

Upvotes: 3

Related Questions