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

Entity Framework considerations with Blazor in Preview 7 #15833

Open
danroth27 opened this issue Jul 25, 2019 · 8 comments
Open

Entity Framework considerations with Blazor in Preview 7 #15833

danroth27 opened this issue Jul 25, 2019 · 8 comments

Comments

@danroth27
Copy link

From @owaits on Thursday, July 25, 2019 2:32:05 PM

When you upgrade to the Preview 7 version of Entity Framework you get a compiler error which indicates you must upgrade to .netstandard2.1. If you do this on a Blazor project and then run the project you get the following error when trying to deserialize JSON.

WASM: System.AggregateException: One or more errors occurred. (VTable setup of type System.Text.Json.Utf8JsonWriter failed)

This makes sense as Blazor does not support .netstandard2.1. So you have to go back to .netstandard2.0 and downgrade Entity Framework to Preview 5 which seems to be the last version of Entity Framework you can use in a Blazor project.

I am just flagging this to help other users and maybe to raise awareness that this may be a problem going forwards as I would expect people to install the latest packages when using Entity Framework.

Copied from original issue: dotnet/aspnetcore#12568

@danroth27
Copy link
Author

From @ericstj on Thursday, July 25, 2019 7:57:04 PM

From https://github.com/dotnet/corefx/issues/39767.

@JoelW187 commented

Just installed Core 3 preview 7 and created a test Blazor app using the default templates. When targeting the client at ".NET Standard 2.0" the application runs and works as expected. When targeting ".NET Standard 2.1" the app compiles and launches but after loading the framework libraries (mono and webassembly) the exception below is thrown and the app stops. I'm using
VS 2019 Preveiw 16.3.0 and launching under IISExpress. To repro just create a Blazor hosted app and change the "Client" app to target ".NET Standard 2.1".

blazor.webassembly.js:1 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
blazor.webassembly.js:1 WASM: at System.Text.Json.JsonSerializer.WriteCoreString (System.Object value, System.Type type, System.Text.Json.JsonSerializerOptions options) <0x1c52b28 + 0x00044> in :0
blazor.webassembly.js:1 WASM: at System.Text.Json.JsonSerializer.ToStringInternal (System.Object value, System.Type type, System.Text.Json.JsonSerializerOptions options) <0x1c527b8 + 0x0000c> in :0
blazor.webassembly.js:1 WASM: at System.Text.Json.JsonSerializer.Serialize[TValue] (TValue value, System.Text.Json.JsonSerializerOptions options) <0x1c526f8 + 0x0000c> in :0
blazor.webassembly.js:1 WASM: at Microsoft.JSInterop.JSInProcessRuntimeBase.Invoke[TValue] (System.String identifier, System.Object[] args) <0x1c22778 + 0x00014> in <0451d7e25d89403c929d2b8ba87c7234>:0
blazor.webassembly.js:1 WASM: at Microsoft.AspNetCore.Blazor.Rendering.WebAssemblyRenderer.AddComponentAsync (System.Type componentType, System.String domElementSelector) <0x1bdcda8 + 0x00066> in <0538dd4072404eb2a3f2b5d81b656f78>:0
blazor.webassembly.js:1 WASM: at Microsoft.AspNetCore.Blazor.Hosting.WebAssemblyBlazorApplicationBuilder.CreateRendererAsync () <0x1bbb890 + 0x000b2> in <0538dd4072404eb2a3f2b5d81b656f78>:0
blazor.webassembly.js:1 WASM: at Microsoft.AspNetCore.Blazor.Hosting.WebAssemblyHost.StartAsyncAwaited () <0x1ba1b78 + 0x001f8> in <0538dd4072404eb2a3f2b5d81b656f78>:0
blazor.webassembly.js:1 WASM: --- End of inner exception stack trace ---
blazor.webassembly.js:1 WASM: ---> (Inner Exception #0) System.TypeLoadException: VTable setup of type System.Text.Json.Utf8JsonWriter failed
blazor.webassembly.js:1 WASM: at System.Text.Json.JsonSerializer.WriteCoreString (System.Object value, System.Type type, System.Text.Json.JsonSerializerOptions options) <0x1c52b28 + 0x00044> in :0
blazor.webassembly.js:1 WASM: at System.Text.Json.JsonSerializer.ToStringInternal (System.Object value, System.Type type, System.Text.Json.JsonSerializerOptions options) <0x1c527b8 + 0x0000c> in :0
blazor.webassembly.js:1 WASM: at System.Text.Json.JsonSerializer.Serialize[TValue] (TValue value, System.Text.Json.JsonSerializerOptions options) <0x1c526f8 + 0x0000c> in :0
blazor.webassembly.js:1 WASM: at Microsoft.JSInterop.JSInProcessRuntimeBase.Invoke[TValue] (System.String identifier, System.Object[] args) <0x1c22778 + 0x00014> in <0451d7e25d89403c929d2b8ba87c7234>:0
blazor.webassembly.js:1 WASM: at Microsoft.AspNetCore.Blazor.Rendering.WebAssemblyRenderer.AddComponentAsync (System.Type componentType, System.String domElementSelector) <0x1bdcda8 + 0x00066> in <0538dd4072404eb2a3f2b5d81b656f78>:0
blazor.webassembly.js:1 WASM: at Microsoft.AspNetCore.Blazor.Hosting.WebAssemblyBlazorApplicationBuilder.CreateRendererAsync () <0x1bbb890 + 0x000b2> in <0538dd4072404eb2a3f2b5d81b656f78>:0
blazor.webassembly.js:1 WASM: at Microsoft.AspNetCore.Blazor.Hosting.WebAssemblyHost.StartAsyncAwaited () <0x1ba1b78 + 0x001f8> in <0538dd4072404eb2a3f2b5d81b656f78>:0 <---
blazor.webassembly.js:1

@ericstj commented

@pranavkm @danroth27 should this go to blazor? Looks like it's having trouble with Utf8JsonWriter. It's a sealed type that implements 2 interfaces: IDisposable and IAsyncDisposable. I'm guessing its having trouble with IAsyncDisposable. The NETStandard implementation of System.Text.Json depends on the out-of-band definition of IAsyncDisposable, which will require the facade that forwards this to netstandard.dll. Blazor should be able to see these.

Chatted with @danroth27 and he mentioned that this could be due to mono lagging in netstandard2.1 support. I can imagine that if they were missing a typeforward in netstandard.dll for IAsyncDisposable this could happen.

@kjpou1
Copy link
Contributor

kjpou1 commented Jul 26, 2019

@danroth27
See issue as well

@lewing
Copy link
Member

lewing commented Jul 26, 2019

/cc @marek-safar

@thangchung
Copy link

I got the issue after upgraded to .NET Core 3.0 Preview 7 as well

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

@Trolldemorted
Copy link

.NET Core 3.0/netstandard2.1 will be released in two weeks, any updates on this issue? Will it be fixed until then?

@marek-safar
Copy link
Member

We haven't completed the API audit but most APIs should be available increasing likelihood of this working on out of the box with the latest release.

@StevenTCramer
Copy link

StevenTCramer commented Oct 5, 2019

@marek-safar
Just to confirm that on

λ  dotnet --version
3.0.100

with

dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.0.0-preview9.19465.2

I did

 dotnet new blazorwasm --hosted -o Hosted

changed the Shared and Client to

<TargetFramework>netstandard2.1</TargetFramework>

And I get the same error as above #15833 (comment)

@marek-safar
Copy link
Member

@lewing do you know if P9 pulled the latest update from us and do we ship them the hotfix we made for the missing attribute types?

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

7 participants