botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

500 internal server error when upgrading System.IdentityModel.Tokens.Jwt NuGet package

Open sabbour opened this issue 10 years ago • 4 comments

Reproduction steps:

  1. Create a Bot Application
  2. Build and run
  3. Connect using the Channel Emulator, it works
  4. Right click on the Bot Application project and Manage NuGet packages
  5. Update packages
  6. Build and run
  7. Connect using the Channel Emulator and send a message, it fails with 500 Internal Server Error

Further investigation surfaces the following: Exception thrown: 'System.TypeLoadException' in mscorlib.dll ("Could not load type 'System.IdentityModel.Tokens.TokenValidationParameters' from assembly 'System.IdentityModel.Tokens.Jwt, Version=5.0.0.127, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.")

sabbour avatar Sep 18 '16 12:09 sabbour

I can confirm that manually downgrading System.IdentityModel.Tokens.Jwt to 4.0.3.308261200 fixed the issue. Any idea what's wrong here?

sabbour avatar Sep 18 '16 12:09 sabbour

I think the System.IdentityModel.Tokens.Jwt 5.0 assembly isn't backward-compatible with the 4.0 signature. Nuget makes it easy to upgrade everything in the project to the latest version, and our version reference doesn't exclude 5.0 (in part because we referenced 4.0 before we knew 5.0 would include breaking changes. :)

I think we can clean up the nuspec (have to check with @msft-shahins) but in the meantime your fix is the right one.

dandriscoll avatar Sep 18 '16 15:09 dandriscoll

Adding the bug flag as this is something we could block in our nuspec file. The workaround above should be sufficient for anyone hitting this issue.

dandriscoll avatar Sep 18 '16 18:09 dandriscoll

fyi, I encountered the same issue and can confirm the reproduction of issue + workaround.

I've encountered similar issues with other nuget packages such as Microsoft.IdentityModel.Clients.ActiveDirectory where latest version relies on System.Net.Http 4.1.0 which is not compatible with WebApi it seems.

rzmoz avatar Sep 19 '16 01:09 rzmoz