TWILIO REST API Helper Library - Issue with NewtonSoft.Json Version

Viewed 177

We have installed the latest Twilio version(5.69.0) in our .NET project (.NETFramework Version is 4.6.2)and updated the following.

Microsoft.Identitymodel.Token (Version:6.15.0)
System.Identity.Model.Token.jwt (Version:6.15.0)
Newtonsoft.Json- (Version:12.0.2)
In the description it is said that we can use Newtonsoft.Json version >=10.0.1(Please see the screenshot)

But we are getting the following error.

System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
   at Twilio.Clients.TwilioRestClient.ProcessResponse(Response response)
   at Twilio.Clients.TwilioRestClient.Request(Request request)
   at Twilio.Rest.Api.V2010.Account.RecordingResource.Read(ReadRecordingOptions options, ITwilioRestClient client)
   at Twilio.Rest.Api.V2010.Account.RecordingResource.Read

Nuget Description

Please advise.

Thanks in advance.

1 Answers

Hi Twilio Evangelist here,

Sorry that you're having this issue. This unfortunately is one that comes up from time to time. I'm not entirely sure that this is caused by Twilio and unfortunately, we've not been able to reproduce it.

However here are some options that may help you get going here.

  1. You can use the bindingRedirect feature to force .NET to use a specific version of Newtonsoft.JSON in your project. If you have an app.config (or a web.config) file, you can include this in the runtime element of your config file. Below is an example
<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0-12.0.2" newVersion="12.0.2" />
      </dependentAssembly>
  </assemblyBinding>
</runtime>
  1. You can reach out to me at corey[at]twilio.com via email if you need additional support.
Related