Is it possible to use the signed RestSharp NuGet package with Twilio?

3

We're using both DocuSign's API which requires the signed version of RestSharp, and we're looking to integrate Twilio which requires the unsigned version. I've spent a bit of time trying to get both DLLs to resolve for each of their dependencies, and haven't had any luck. At this point, I'm hoping there's a way to use the signed RestSharp dll with Twilio. Has anyone had any experience with this before?

When I attempt to remove the unsigned RestSharp, my DocuSign code works fine, but now TwilioRestClient is unable to resolve the dependencies. Both libraries are 105.2.3.0.

An exception of type 'System.IO.FileLoadException' occurred in Twilio.Api.dll but was not handled in user code.

Additional information: Could not load file or assembly 'RestSharp, Version=105.2.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

c#
.net
twilio
restsharp
asked on Stack Overflow Oct 7, 2016 by DevTech

1 Answer

2

This is issue has been a nightmare for me. In my case I was using EasyPost which used RestSharpSigned. Same difference.

I ultimately had to stop relying directly on nuget for packages that referenced RestSharp. And used a tool to add a strong naming to 3rd party dlls. It also fixes reference to unsigned dlls to the newly signed ones.

  1. I copied all the DLLs from /packages/ (easypost, twilio, restsharp) into a directory in the root of my solution called "resources". These will eventually be checked in to your source control.

  2. Make a copy of the resources directory on your desktop. If something screws up you want to have a quick way to recopy a fresh set of untouched files.

  3. Right click on the solution and hit "manage nuget packages for the solution". Remove the nuget packages for Twilio, EasyPost, Restsharp, RestSharpSigned, and anything that relies on RestSharp and now has a copy in resources. As you do this, make a note of which of your projects referenced which assemblies. This is important for later. Note: removing the package from all projects will delete the reference.

  4. Download Brutal Developer's Strong Namer Signer. Add all the dlls in /resources/ via the green plus icon. It is ok if some of them are already signed.

  5. Hit "Sign Assemblies", it will sign all unsigned assemblies and will fix the references between them to point at the newly signed versions.

  6. Go through your projects and add direct dll references.

  7. Build and run your app to ensure you don't hit any weird runtime errors about missing assemblies.

  8. In a raised voice, shout "Fucking Finally!" in triumph. Shake your Fist at the .Net Gods in the sky for all the trouble strong naming has caused you and millions of other devs.

Ultimately, my plan is to migrate to the latest version of Twilio (5.*) which no longer has a dependency on RestSharp at all. Once that happens, I'm going to kill my "references" folder and just go back to plain ole nuget for these packages.

enter image description here

answered on Stack Overflow Jun 2, 2017 by viggity • edited Sep 6, 2017 by viggity

User contributions licensed under CC BY-SA 3.0