Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Targeting Blazor WebAssembly project to .NET Standard 2.1 breaks at runtime #16765

Closed
danroth27 opened this issue Sep 10, 2019 · 17 comments
Closed
Assignees

Comments

@danroth27
Copy link

Repro steps:

  • Create a new Blazor WebAssembly app
  • Update the client project to target netstandard2.1
  • Build and run.

Expected result: Runs successfully

Actual result:

WASM: System.AggregateException: One or more errors occurred. (VTable setup of type System.Text.Json.Utf8JsonWriter failed) ---> System.TypeLoadException: VTable setup of type System.Text.Json.Utf8JsonWriter failed
WASM:   at System.Text.Json.JsonSerializer.WriteCoreString (System.Object value, System.Type type, System.Text.Json.JsonSerializerOptions options) <0x1ce3bf0 + 0x00044> in <81e9245ca982431695a55cc67ffb3b86>:0 
WASM:   at System.Text.Json.JsonSerializer.ToStringInternal (System.Object value, System.Type inputType, System.Text.Json.JsonSerializerOptions options) <0x1ce3880 + 0x0000c> in <81e9245ca982431695a55cc67ffb3b86>:0 
WASM:   at System.Text.Json.JsonSerializer.Serialize[TValue] (TValue value, System.Text.Json.JsonSerializerOptions options) <0x1ce37c0 + 0x0000c> in <81e9245ca982431695a55cc67ffb3b86>:0
WASM:   at Microsoft.JSInterop.JSInProcessRuntime.Invoke[TValue] (System.String identifier, System.Object[] args) <0x1ce3678 + 0x0001e> in <b57783c7fafa47088562351a82800d2f>:0
WASM:   at Microsoft.AspNetCore.Blazor.Rendering.WebAssemblyRenderer.AddComponentAsync (System.Type componentType, System.String domElementSelector) <0x1c859d8 + 0x00064> in <3914758d3a6d4113a921804c5fa45f6c>:0
WASM:   at Microsoft.AspNetCore.Blazor.Hosting.WebAssemblyBlazorApplicationBuilder.CreateRendererAsync () <0x1c427e8 + 0x000dc> in <3914758d3a6d4113a921804c5fa45f6c>:0
WASM:   at Microsoft.AspNetCore.Blazor.Hosting.WebAssemblyHost.StartAsyncAwaited () <0x1c29e38 + 0x001ec> in <3914758d3a6d4113a921804c5fa45f6c>:0
WASM:    --- End of inner exception stack trace ---
WASM: ---> (Inner Exception #0) System.TypeLoadException: VTable setup of type System.Text.Json.Utf8JsonWriter failed
WASM:   at System.Text.Json.JsonSerializer.WriteCoreString (System.Object value, System.Type type, System.Text.Json.JsonSerializerOptions options) <0x1ce3bf0 + 0x00044> in <81e9245ca982431695a55cc67ffb3b86>:0
WASM:   at System.Text.Json.JsonSerializer.ToStringInternal (System.Object value, System.Type inputType, System.Text.Json.JsonSerializerOptions options) <0x1ce3880 + 0x0000c> in <81e9245ca982431695a55cc67ffb3b86>:0
WASM:   at System.Text.Json.JsonSerializer.Serialize[TValue] (TValue value, System.Text.Json.JsonSerializerOptions options) <0x1ce37c0 + 0x0000c> in <81e9245ca982431695a55cc67ffb3b86>:0
WASM:   at Microsoft.JSInterop.JSInProcessRuntime.Invoke[TValue] (System.String identifier, System.Object[] args) <0x1ce3678 + 0x0001e> in <b57783c7fafa47088562351a82800d2f>:0
WASM:   at Microsoft.AspNetCore.Blazor.Rendering.WebAssemblyRenderer.AddComponentAsync (System.Type componentType, System.String domElementSelector) <0x1c859d8 + 0x00064> in <3914758d3a6d4113a921804c5fa45f6c>:0
WASM:   at Microsoft.AspNetCore.Blazor.Hosting.WebAssemblyBlazorApplicationBuilder.CreateRendererAsync () <0x1c427e8 + 0x000dc> in <3914758d3a6d4113a921804c5fa45f6c>:0
WASM:   at Microsoft.AspNetCore.Blazor.Hosting.WebAssemblyHost.StartAsyncAwaited () <0x1c29e38 + 0x001ec> in <3914758d3a6d4113a921804c5fa45f6c>:0 <---

Workaround:

Disable the IL linker by setting <BlazorLinkOnBuild>false</BlazorLinkOnBuild>.

@danroth27
Copy link
Author

danroth27 commented Sep 10, 2019

@lewing @SteveSandersonMS

@marek-safar
Copy link
Member

This looks like some new metadata issue in linker. @lewing could you extract linker repro out of this?

@BenjaminCharlton
Copy link

Don't mean to hassle, but I was just wondering if this will be complete by the time the final release of .NET Core 3.0 comes out later in the month?

@danroth27
Copy link
Author

@BenjaminCharlton No, this fix won't be ready in time for the next preview Blazor Webassembly release that's going out with the NET Core 3.0 release. It will be a few more weeks until we have a fix for this.

@BenjaminCharlton
Copy link

Ok thanks for the information. Keep up the great work!

@Herdo
Copy link

Herdo commented Oct 11, 2019

Will this be fixed with .NET Core 3.1, the Blazor WASM release in May 2020, or at a different point in time?

@Herdo
Copy link

Herdo commented Oct 11, 2019

Related to #15833 ?

@Rauce
Copy link

Rauce commented Oct 15, 2019

Just came across this issue myself and found it here.

Until this is fixed, we cannot use C# 8 language features in a Blazor app, as to do so requires targeting .NET Standard 2.1 :-(

@mkArtakMSFT
Copy link

@marek-safar what's the latest on this?

@lewing
Copy link
Member

lewing commented Oct 22, 2019

I spent some time looking at this today and it appears to be related to assembly resolution when the linker is used. In particular after the linker has run we appear to be ending up with a version of System.Threading.Tasks.Extensions.dll that triggers the issue. If I replace that assembly with the mono bcl version the app starts correctly.

@mkArtakMSFT
Copy link

Thanks @lewing. Is this something you have control over of is this something we break somewhere in Blazor?

@lewing
Copy link
Member

lewing commented Oct 30, 2019

I think I've found the issue here, testing now.

@lewing
Copy link
Member

lewing commented Oct 30, 2019

dotnet/aspnetcore@master...lewing:resolve-with-linker is a quick workaround that demonstrates the problem. In the linker case _BlazorDependencyInput references assemblies that have been resolved against the wrong bcl. The workaround uses the linker to resolve the assemblies and orders the directories so that we resolve against the wasm bcl first.

/cc @SteveSandersonMS

@SteveSandersonMS
Copy link
Contributor

Thanks Larry! It seems clear then that this is not a Mono issue, but rather is something we need to update in Blazor, which I'm doing based on your approach at dotnet/aspnetcore#16808.

This can be closed IMO.

@kjpou1
Copy link
Contributor

kjpou1 commented Nov 29, 2019

Closing this based on issue discussions

@kjpou1 kjpou1 closed this as completed Nov 29, 2019
@ebbypeter
Copy link

So is this issue fixed? or moved to a dofferent repo?

@danroth27
Copy link
Author

Hi @ebbypeter. Targeting .NET Standard 2.1 should be working with the latest Blazor WebAssembly previews. If you're finding otherwise, please let us know by opening a new issue with details about the problem you're seeing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests