2

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.

Agent 47
  • 33
  • 6
  • Please note: We can't use NewtonSoft.Json version 10.0.1 and can only use version > 12.0 since we are using push notification feature in our application. – Agent 47 Jan 12 '22 at 04:51
  • 1
    I’m voting to close this question because you need to contact the Vendor – jazb Jan 12 '22 at 05:02

1 Answers1

1

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.
Corey Weathers
  • 419
  • 3
  • 5
  • This code snippet isn't even valid XML. Where's the opening tag for `dependentAssembly`? – Jacob Stamm Feb 22 '22 at 22:50
  • @JacobStamm thanks for calling that out. I've updated it to both fix that issue & add the detailed assemblyBinding namespace. This has just been verified – Corey Weathers Feb 23 '22 at 23:32