Jean Poulin
Jean Poulin

Reputation: 21

Weird problem migrating blazor from .net 5 to .net 6.0

I migrated my blazor WASM + web Api to .Net 6.0. My web API seems OK at least in regard to compile & usage via Postman.

On the client WASM side though, after following all instruction to upgrade + updated my packages including MudBlazor, I have a 1 very weird error. It does not even point to my direct source code but compiled code in the mypage.razor.g.cs at line 1057. Here is the error: Error CS1662 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 BlazorProducts.Client D:\BlazorSurface\OderSDT_PubV2022\Order.Client\BlazorProducts.Client\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_OrderEdit_razor.g.cs 1057 Active

By adding the line true in my .csproj file I was able to look at the Pages_OrderEdit_razor.g.cs file and to this line #1057 below It seems to relate to the EditForm & his EditContect tag and the code is further below my compiled code. I tried some post related to that & tried several things regarding the user of tag Select versus InputSelect in my modal but it did not fixed it. Yes, I have compiled in Debug mode.

Is someone have a clue on how to resolve this error?

1049    #line 245 "D:\BlazorSurface\OderSDT_PubV2022\Order.Client\BlazorProducts.Client\Pages\OrderEdit.razor"
1050                                                                  AddOrderedItem
1051
1052 #line default
1053 #line hidden
1054 #nullable disable
 1055            )));
 1056          __builder.AddAttribute(207, "class", "card card-body bg-light mt-0");
 1057            __builder.AddAttribute(208, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment<Microsoft.AspNetCore.Components.Forms.EditContext>)((context) => (__builder2) => {
 1058               __builder2.OpenElement(209, "div");
 1059               __builder2.AddAttribute(210, "class", "modal-content");
 1060               __builder2.OpenElement(211, "div");
 1061               __builder2.AddAttribute(212, "class", "modal-header");
 1062               __builder2.AddMarkupContent(213, "<h5 class=\"modal-title\">Ajout - item de commande</h5>\r\n                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n                    ");
 1063               __Blazor.BlazorProducts.Client.Pages.OrderEdit.TypeInference.CreateInputSelect_12(__builder2, 214, 215, "form-control", 216, " height: 35px;  border-radius: 5px;", 217, 
 1064 #nullable restore
1065  #line 250 "D:\BlazorSurface\OderSDT_PubV2022\Order.Client\BlazorProducts.Client\Pages\OrderEdit.razor"

+++++++ Razor Code of OrderEdit.razor Line #245 is the line of EditForm tag ++++++++

<div class="modal" tabindex="-1" role="dialog" style="display:@_modalDisplay">

    <div class="modal-dialog" role="document">
        <EditForm EditContext="_editDetailContext" OnValidSubmit="@AddOrderedItem" class="card card-body bg-light mt-0">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Ajout - item de commande</h5>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <InputSelect @bind-Value="@parentCatId.CategoryID" class="form-control" style=" height: 35px;  border-radius: 5px;">
                        @foreach (var cat in _parentCategorySelectList)
                        {
                            <option value="@cat.MyValueField">@cat.MyTextField</option>
                        }
                    </InputSelect>

                    <button type="button" class="close" @onclick="HideAddProduct" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>

….. …..

Upvotes: 0

Views: 212

Answers (1)

WhiskyDogSnow
WhiskyDogSnow

Reputation: 1

Whenever I have seen this delegate error, the cause was that the page was referencing a method name that didn't actually exist so double check if one needs updating.

Upvotes: 0

Related Questions