The type initializer for 'System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler' threw an exception.

See original GitHub issue

I am using a locally compiled version of System.IdentityModel.Tokens.Jwt.6.7.1.nupkg (not from Nuget) and I am getting the exception “The type initializer for ‘System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler’ threw an exception.” from my project when instantiating new JwtSecurityTokenHandler();. I would like to know if there are any leads that will help me resolve the issue.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
GeoKcommented, Dec 1, 2020

@arunswarnam - We are using friend assembly mechanism to access internal classes/methods in other IdentityModel.* assemblies. Are you using a different key to sign these assemblies? If so, that would result in a public key mismatch.

0reactions
arunswarnamcommented, Dec 3, 2020

Thanks @GeoK … The handle you gave regarding Friend Assemblies helped solve the issue. The main issue was delay signing the locally built nuget package with a different key.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The type initializer for System.IdentityModel.Tokens.Jwt. ...
I fixed this issue on mine by deleting the reference for "System.IdentityModel" and only having a reference to "System.IdentityModel.Tokens.
Read more >
Newtonsoft.Json Exception · Issue #1033
Message=The type initializer for 'System.IdentityModel.Tokens.Jwt.JsonExtensions' threw an exception. Source=System.IdentityModel.Tokens.Jwt StackTrace: at ...
Read more >
Auth0 LoginAsync complains about newtonsoft.json dll ...
TypeInitializationException : The type initializer for 'System.IdentityModel.Tokens.Jwt.JsonExtensions' threw an exception. —> System.IO.
Read more >
JwtSecurityTokenHandler Class (System.IdentityModel. ...
Validates a token. On a validation failure, no exception will be thrown; instead, the exception will be set in the returned TokenValidationResult.Exception ......
Read more >
Access Token validating fails with JWTSecurityTokenHandler
Exceptions caught: 'System.Text.StringBuilder'. token: 'System.IdentityModel.Tokens.Jwt.JwtSecurityToken'. Source=TokenTestApp StackTrace: ...
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