Aspnetcore: [BlazorWebassembly] Upgrade to net5.0 rc fails with several errors

Created on 10 Oct 2020  路  7Comments  路  Source: dotnet/aspnetcore

I tried to upgrade an existing application to net5.0. The application builds fine (without optimization), unfortunately the application doesn't load at all. I see several errors. Here's the log file:
localhost-1602332680112.log

One of the errors is:

Error: System.TypeLoadException: Could not resolve type with token 0100003e from typeref (expected class 'System.Runtime.CompilerServices.IAsyncStateMachine' in assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')

The application depends on some razor class libraries (which I updated to net5.0) and some netstandard2.0 libaries.

Needs area-blazor blazor-wasm

Most helpful comment

It's still attempting to run dotnet.3.2.0.js instead of dotnet.5.0.0-rc.1.20451.14.js. It looks like your upgrade may be incomplete.

Which guide did you follow?

Did you do all the things described here as well?

Btw this also mentions to remove any Microsoft.AspNetCore.Components.WebAssembly.Build package reference.

All 7 comments

It's still attempting to run dotnet.3.2.0.js instead of dotnet.5.0.0-rc.1.20451.14.js. It looks like your upgrade may be incomplete.

Which guide did you follow?

Did you do all the things described here as well?

Btw this also mentions to remove any Microsoft.AspNetCore.Components.WebAssembly.Build package reference.

Without Microsoft.AspNetCore.Components.WebAssembly.Build, wwwroot\_framework is empty, except for the empty directories _bin and wasm.

@nikonthethird I did all the required changes. I don't know if it could be related to the netstandard 2.0 projects. They reference some system assemblies and of course not in a 5.0.0-* version

I was able to solve the issues I had.

I was able to solve the issues I had.

Could you please share how you solved it.

Glad that you were able to solve your issue, @TFTomSun.
We're closing this issue. Hope you can share some info with @Robelind as they have similar issue.

@Robelind I had several issues to fix. Here is my working blazor app csproj:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
  <PropertyGroup>
    <TargetFramework>net50</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0-*" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0-*" PrivateAssets="all" />

    <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0-*" />
    <PackageReference Include="System.Threading.Channels" Version="5.0.0-*" />

   <PackageReference Include="TomSun.Net.Blazor.Demo.Common" Version="*" />
  </ItemGroup>
</Project>
  • I missed to define the correct sdk (Microsoft.Net.BlazorWebAssembly ) in the project node
  • I had to add 2 Microsoft.AspNetCore.Component packages to the blazor app (see above) and to all projects that provide razor files (see below).
  • I had to overwrite some package versions to the 5.0.0-* that were referenced in some .net standard projects. I didn't want to touch the netstandard projects directly because they are also used by netcore3.1 apps, that I didn't migrate yet.
  • After all changes I had to delete the obj and bin folders and do a rebuild

A razor library should look like this:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Razor">
  <PropertyGroup>
    <TargetFramework>net50</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components" Version="5.0.0-*" />
    <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="5.0.0-*" />
  </ItemGroup>
  <ItemGroup />
</Project>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

KerolosMalak picture KerolosMalak  路  269Comments

moodya picture moodya  路  153Comments

clement911 picture clement911  路  129Comments

zorthgo picture zorthgo  路  136Comments

reduckted picture reduckted  路  91Comments