JsonSerializer error in Visual Studio 2022 (preview)

See original GitHub issue

Hi all, When calling GetDiscoveryDocumentAsync in my Xamarin.Forms project, inside Vs2022 i get this error

_discoveryResponse = await _tokenClient.GetDiscoveryDocumentAsync(new DiscoveryDocumentRequest
{
	Address = App.Current.AppSettings.AuthEndpointUrl,
});

Error connecting to endpoint Error connecting to https://{myidentityserverurl}/.well-known/openid-configuration/jwks. The type initializer for ‘System.Text.Json.JsonSerializer’ threw an exception.

This not happen when using VS 2019 or from device (without debugger attached)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
RichWoollcottcommented, Mar 16, 2022

Hi I encountered this problem with a Xamarin.Forms app and found a solution here.

I have a working example in the WebAuthenticatorDemo-OIDCClient folder.

I used the nuget package references:- IdentityModel.OidcClient v5.0.0 System.Text.Json v6.0.2

Add this to the iOS project file:-

<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> 

Set the project (Xamarin.Forms in this case) to use .Net standard 2.1

Hope this helps

1reaction
rogmauricommented, Nov 26, 2021

@amellini I used your text reporting the problem and registered it in the visual studio community. Follow the link below. If everyone reinforces the request, it would help.

https://developercommunity.visualstudio.com/search?space=61&q=System.Text.Json.JsonSerializer+error+visual+studio+2022

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - How do I fix the error "Could not load file or assembly ' ...
Solution for me was updating Visual Studio to the latest version that came with .NET 7 SDK and updating the project target framework...
Read more >
StreamJsonRpc.RemoteInvocationException while ...
Fresh install of Visual Studio 2022 results in a StreamJsonRpc.RemoteInvocationException exception... Checked the log under C:\Users[myId]\AppData\Local\Temp\ ...
Read more >
How to serialize and deserialize JSON using C# - .NET
To write JSON to a string or to a file, call the JsonSerializer.Serialize method. The following example creates JSON as a string: C#...
Read more >
Blazor WASM Dotnet6-Preview7, InvalidOperationException ...
InvalidOperationException: There was an error parsing the event arguments. EventId: '2'. ... Json.Serialization. ... Visual Studio 2022 (17.0.0 Preview 3.0) ...
Read more >
Support "import" statement in module interface files. #3424
Description I'm using MSVC 2022 with /std:c++20. I'm trying to import single_include version 3.10.5 into my module interface file (*.ixx).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found