fsbolero / Bolero

Bolero brings Blazor to F# developers with an easy to use Model-View-Update architecture, HTML combinators, hot reloaded templates, type-safe endpoints, advanced routing and remoting capabilities, and more.
https://fsbolero.io
Apache License 2.0
1.06k stars 53 forks source link

TypeLoadException with Bolero 0.16 and .NET 5.0 #192

Closed kojo12228 closed 3 years ago

kojo12228 commented 3 years ago

Thanks to Bolero 0.16 release, my previous issue #191 has been resolved. However, I have two new problems:

Using the following packages:

Client Package Version
Bolero 0.16.26
Bolero.Build 0.16.26
Bolero.HotReload 0.16.13
Microsoft.AspNetCore.Components.WebAssembly.Build 3.2.1
Microsoft.AspNetCore.Components.WebAssembly.DevServer 5.0.0
Server Package Version
Bolero.Server 0.16.26
Bolero.HotReload.Server 0.16.13
Microsoft.AspNetCore.Components.WebAssembly.Server 5.0.0
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 5.0.0

I get the following exception in the browser console:

Unhandled Exception:
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')
blazor.webassembly.js:1 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')
    at Object.call_method (dotnet.3.2.0.js:1)
    at dotnet.3.2.0.js:1
    at Object.callEntryPoint (blazor.webassembly.js:1)
    at blazor.webassembly.js:1
    at blazor.webassembly.js:1
    at Object.next (blazor.webassembly.js:1)
    at i (blazor.webassembly.js:1)

Removing Microsoft.AspNetCore.Components.WebAssembly.Build to match the current 16.5 Template causes other resources to not load.

Again, on my machine, creating a fresh Bolero 16 Hello World application works. Further, creating a fresh clone of my application and copying over the 16.5 template package versions (with and without WebAssembly.Build) throws the same errors.

I'm would definitely be up for contributing to the fix, but I wouldn't know where to start.

Tarmil commented 3 years ago

Oh, I just realized that the 0.16 entry in the Upgrade guide failed to publish :/ Here it is on GitHub while I fix this. You indeed need to remove Microsoft.AspNetCore.Components.WebAssembly.Build; I believe the part you are missing is changing the Sdk of the client project to Microsoft.NET.Sdk.BlazorWebAssembly.

kojo12228 commented 3 years ago

Thanks @Tarmil! My project is working now, I'll close the issue