0

I am seeing a System.Reflection.ReflectionTypeLoadException at runTime:

Could not load type 'System.IdentityModel.Tokens.ISecurityTokenValidator' from assembly 'System.IdentityModel.Tokens.Jwt, Version=5.0.0.127, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.":"System.IdentityModel.Tokens.ISecurityTokenValidator

I am using System.IdentityModel.Tokens.Jwt version 5.0.0.127 (nuget package 5.0.0)

I have tried using fuslog to look at the binding log. It finds the dll in my bin directory and the bind succeeds (and it is the correct dll). I've also verified that I don't have this library installed in the GAC.

I used visual studio's object browser and went looking through the dll. I found that JwtSecurityTokenHandler inherits from ISecurityTokenValidator. According to the object browser ISecurityTokenValidtor comes from Microsoft.IdentityModel.Tokens. (I am using nuget package 5.0.0 of that one also).

I manually went through the various nuget dependencies related to these two packages (as well as any others in my project that I thought had a chance of being relevant). Everything appears to check out.

Can anyone explain under what circumstances you would be unable to load a type from an assembly? And can anyone explain to me how to properly resolve the issue with this specific library?

user1892134
  • 111
  • 2
  • 4
  • Could you add the full stacktrace and the code surrounding where the error occurs? – Bardicer Jun 16 '17 at 19:06
  • 1
    You need to go backward to System.IdentityModel.Tokens.Jwt version 4. They removed a class from the v5 assemblies, which breaks everything. Read about this [issue here](https://github.com/IdentityServer/IdentityServer3/issues/3017). [This question](https://stackoverflow.com/questions/38119877/tokenvalidationparameters-no-longer-working-after-upgrade-to-5-0-0) is also related. –  Jun 16 '17 at 19:08
  • Basically, Microsoft messed up by removing a class or two and incorrectly setting Nuget dependency versions. –  Jun 16 '17 at 19:16

1 Answers1

1

In My case I removed the "Microsoft.IdentityModel.Protocol.Extensions" from my packages. and worked like a charm.

Mahdi Shahbazi
  • 1,063
  • 1
  • 10
  • 13