500 internal server error when upgrading System.IdentityModel.Tokens.Jwt NuGet package
Reproduction steps:
- Create a Bot Application
- Build and run
- Connect using the Channel Emulator, it works
- Right click on the Bot Application project and Manage NuGet packages
- Update packages
- Build and run
- 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'.")
I can confirm that manually downgrading System.IdentityModel.Tokens.Jwt to 4.0.3.308261200 fixed the issue. Any idea what's wrong here?
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.
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.
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.