MobileBlazorBindings
MobileBlazorBindings copied to clipboard
BlazorHybrid template error on runtime: Type initializer for ElementReferenceJsonConverter threw
When I run the android project on macOs the screen show and throw a error
The screen is showed and desapear and this error take place.
But I have ran the others projects with success: iOS; macOs.
Just the android project that does not work.
The BlazorMobileBindings template work with not any problem all project works.
I know I've seen this before, but again I can't figure out where! It's odd that it's just Android, because this code should be quite similar, if not identical, on all platforms.
Did you by any chance use Debug or Release mode? Or do some sort of app trimming? Or is this just the basic template running with all default settings?
Just the basic template running with all default settings. My machine is a macOs catalina, but at my work I have imac with big sur. And I have the same error.
On windows, the android works fine! What would be if the template is that same ? The template repository is the same? Or something is wrong in the version for macOs. Or something is wrong in the msbuild pipeline on macOs?
https://user-images.githubusercontent.com/7851330/111405651-9f99fd00-86af-11eb-92b5-a2211dd5df32.mov
This is what are going when the app is started.
Hi guys. I have the identical problem, but it happens when I run the iOS project, not Android. Any progress about it?
So I added this code to iOS .csproj file and now it works fine for me. Hope it is useful to someone.
<ItemGroup>
<PackageReference Include="System.Memory" Version="4.5.4">
<IncludeAssets>none</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Buffers" Version="4.5.1">
<IncludeAssets>none</IncludeAssets>
</PackageReference>
</ItemGroup>
I am also experiencing this on the Android side. Curiously though, if I close the app in the simulator (which disconnects my VS debugger), then relaunch it, the error does not appear.
Experiencing the same as @GravlLift
I am having the same issue as @GravlLift. My PC is running on Win10 and I am using the VS 2022.
UPDATE: I managed to fix the issue by updating the System.Net.Http.Json (in the shared project) and System.Text.Encodings.Web (in Android project) to 6.0.0. In the initial template they are still supporting 3.X.X versions. @GarageGadget @GravlLift @ricardoromaobr please advise if this fixes the problem for you as well, so the issue can be addressed accordingly.
UPDATE: I managed to resolve the issue by updating the packages to latest versions, followed by Clean and Rebuild.
@Eilon Is there going to be an update for the hybrid templates so this issue can be avoided in the future?
i fix this issue by updating System.Net.Http.Json(in app project) and System.Text.Encodings.Web(in android project) and System.Text.Json(in windows project) to the latest version(6.0.0) and subsequently build the solution.