Friday, December 22, 2017

WSFederation OWIN - Could not load type 'System.IdentityModel.Tokens.TokenValidationParameters' from assembly 'System.IdentityModel.Tokens.Jwt, Version=5.0.0.127, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

At one of my clients we are (still) using ASP.NET MVC 5 and Web API 2. To secure these web applications we use the WSFederation OWIN middleware together with ADFS. This combination works nice and helps us keeping our applications secure.

Today one of the teams contacted me and complained that the middleware no longer worked. The error message they got looked like this:

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

The root cause of the problem could be found in the version number, they accidently upgraded the System.IdentityModel.Tokens.Jwt assembly from version 4 to 5. It turns out that version 5 is no longer compatible with OWIN.

After reverting back to version 4, everything returned back to normal…

2 comments:

وحيد نصيري said...

Recently I updated a JWT sample to V5. `Microsoft.IdentityModel.Tokens 5.2.0-preview2-41113220915` is compatible with `Microsoft.Owin 4.0.0-preview1`. You can find its other changes here.

Bart Wullems said...

Thx for the info. I'll try it myself...