JWT Token BouncyCastle exception


I developed a program to use the DocuSign API but I have a problem when I try to receive a JWT Token. I get the following exception:

System.IO.FileLoadException: 'Could not load file or assembly 'BouncyCastle.Crypto, Version=, Culture=neutral, PublicKeyToken=0e99375e54769942' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

Here is the code I am testing.

public void GetToken()
    OAuth.OAuthToken authToken = ApiClient.RequestJWTUserToken(ClientID, ImpersonatedUserGuid, 
       AuthServer, Encoding.UTF8.GetBytes(PrivateKey), 1);

    AccessToken = authToken.access_token;

    if (Account == null)
       Account = GetAccountInfo(authToken);

asked on Stack Overflow Apr 8, 2020 by Sara Chalokh • edited Apr 9, 2020 by mike

1 Answer


You need to ensure that you have all the dependent DLLs. Nuget manager many not remove them when you remove a package in some cases because they're used by other things as well as when you upgrade you may not get new ones. If you can, remove all nuget packages and re-add them again. If that's too much, you would have to add the ones that are missing manually. Note also that a solution has multiple projects and the VS would allow you to pick which project for which nuget package. You can always just manually edit the .csproj file as well to add the missing reference, if the package is there but just not being linked.

answered on Stack Overflow Apr 9, 2020 by Inbar Gazit

User contributions licensed under CC BY-SA 3.0