17

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()
Megan Speir
  • 3,745
  • 1
  • 15
  • 25
Thugge
  • 208
  • 1
  • 4
  • 10
  • Twilio uses the RestSharp library so it looks like that dependency has failed for some reason. Try to add ReshSharp to your project: Install-Package RestSharp – Rune Grimstad May 06 '16 at 06:21

5 Answers5

15

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.

Xavier Peña
  • 7,399
  • 9
  • 57
  • 99
  • 1
    This "worked" for me, but what's weird is that I was only seeing the error during unit tests (that funneled down to some of the Twilio code). However, in my main application I didn't have any issue at all with the Twilio library. – Evan Apr 12 '17 at 15:10
  • THIS!! I had this exact same issue but with a different library! ePay/ePayPolicy/ePay3 causes the exact same problem. It basically installs whatever RestSharp/ReSharp it can find, but demands you have this exact version (105.2.3.0) or it fails at runtime. A very bad time to find an important error like that. – Chris Moschini Sep 01 '19 at 14:07
  • 1
    @evan The reason it fails in tests but not at runtime is because at runtime different projects all deploy to different directories. But During unit tests (especially build server unit tests) all the DLLs get dumped into the same dir. If there are conflicting dlls, one of them "wins" and the code looking for the other version will fail – Jason Coyne Apr 14 '20 at 19:29
12

When you are adding a reference to RestSharp, be aware of the version number (Version=105.2.3.0).

Also, your project's .net framework should be higher or equal then the referenced dll's.

aniski
  • 1,263
  • 1
  • 16
  • 31
6
  1. Remove all references form Restsharp.

  2. Clean Solution (Clean solution option)

  3. Add RestSharpSigned.105.2.3 (find by name RestSharpSigned).

    it's work.

Community
  • 1
  • 1
  • Why does this exist? RestSharpSigned package exists and only exists for version 105.2.3. Was there a problem with this version? I know that I get runtime exceptions when referencing the normal RestSharp.105.2.3 from signed assemblies. They say they can only use other signed assemblies. Why wasn't this one signed? Is it the only one not signed? Why are so many people, including us, using it? – Triynko Apr 01 '21 at 03:17
  • It is simply an old version, if you have the freedom to remove it and use a newer do it, this case is simply because there are applications that use that version and there is no time to update them, only that. – Norberto Castellanos Apr 06 '21 at 20:18
0

The error messages states that you don't have RestSharp reference. Have a look and include it as a reference. Make sure to select the reference and select "Copy Local" option from the properties window in Visual Studio

Sam
  • 2,917
  • 1
  • 15
  • 28
0

Getting error because Assembly(DLL) of 'RestSharp' Version=105.2.3.0 is not available in your solution. You can check in Project -> references in VS. In some case, RestSharp Assembly available but of different version.

In that case, First Right Click "Remove" older Assembly. Then "Add reference" by right clicking on References and "Browse" required Assembly in Your Drive..It is expected to be in packages folder. And Rebuild.

Yogesh Dangre
  • 181
  • 1
  • 4