Could not load file or assembly 'RestSharp, Version=105.2.3.0

Thugge picture Thugge · May 6, 2016 · Viewed 20.8k times · Source

I am having some trouble understanding this issue.

I have a local project with Twilio added via Nuget. But when I export the project to my IIS server, it cannot use Twilio, even if i have added all the DLL files for Twilio.

I think I am missing something with the include or something..

This is the errormessage i get:

Exception information: 
    Exception type: FileNotFoundException 
    Exception message: Could not load file or assembly 'RestSharp, Version=105.2.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
   at Twilio.TwilioClient..ctor(String accountSid, String authToken, String accountResourceSid, String apiVersion, String baseUrl)
   at Twilio.TwilioRestClient..ctor(String accountSid, String authToken, String accountResourceSid) in C:\projects\twilio-csharp\src\Twilio.Api\Core.cs:line 182
   at Modules.Messaging.TwilioClient.Send()

Answer

Xavier Peña picture Xavier Peña · Oct 17, 2016

I had the same issue, and I've finally found how to solve it.

The thing is: when you install Twilio through NuGet, it installs RestSharp as a dependency. BUT for some reason, the installed version of RestSharp is Version=105.2.2.0 (instead of Version=105.2.3.0, which Twilio seems to be looking for at runtime).

So how do you solve that?

  1. Go to your installed NuGet packages
  2. Select RestSharp
  3. Update it to the version 105.2.3.0 (with the blue-arrow icon)

Why the NuGet Twilio bundle installs RestSharp Version=105.2.2.0 and then at runtime looks for RestSharp Version=105.2.3.0? No idea.