12

Using APIs from Docusign, Twilio and Auth0. All 3 have RestSharp.dll as a dependency.

If I use the RestSharp.dll included with the Docusign package, Docusign works well but Auth0 and Twillio give errors:

Could not load file or assembly 'RestSharp, Version=104.1.0.0, Culture=neutral, PublicKeyToken=null'

If I use the normal RestSharp.dll (Install-Package RestSharp), Twilio and Auth0 work fine but I get an error when using Docusign:

Could not load file or assembly 'RestSharp, Version=100.0.0.0, Culture=neutral, PublicKeyToken=5xxxxxxxxxxxx'

Adding binding redirects does not solve the issue. Without binding redirects, I get this error in the log:

Comparing the assembly name resulted in the mismatch: MAJOR VERSION.

If I do use a binding redirect:

Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN.

Binding redirect code:

<dependentAssembly>
    <assemblyIdentity name="RestSharp" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-105.2.3.0" newVersion="105.2.3.0" />
 </dependentAssembly>
techspider
  • 3,370
  • 13
  • 37
  • 61
Ben B
  • 335
  • 1
  • 5
  • 18

1 Answers1

12

Temporarily solved the issue by renaming the RestSharp.dll that was included with the Docusign package to "RestSharpDocusign.dll" and copied that into my project.

I modified the assembly bindings so that when version 100.0.0.0 was called it would load the special "RestSharpDocusign.dll" with the publicKeyToken Docusign wanted. Anything else would utilize the standard RestSharp.dll with a null publicKeyToken.

<dependentAssembly>
    <assemblyIdentity name="RestSharp" publicKeyToken="null" culture="neutral" />
    <bindingRedirect oldVersion="100.0.0.1-105.2.3.0" newVersion="105.2.3.0" />
</dependentAssembly>
<dependentAssembly>
    <assemblyIdentity name="RestSharp" publicKeyToken="598062e77f915f75" culture="neutral" />
    <codeBase version="100.0.0.0" href="ult/RestSharpDocusign.dll" />
</dependentAssembly>
Ben B
  • 335
  • 1
  • 5
  • 18
  • 11
    Seems kinda nutty that at this stage of the game we're reduced to playing these games straight outta 90's DLL Hell. – Ken Smith Aug 17 '16 at 22:15
  • 1
    You're telling me! Luckily the DocuSign API is open so I was able to update RestSharp and recompile the DLL. Once I added that into my project everything worked OK. – Ben B Aug 17 '16 at 22:25
  • For me it was the HelloSign API triggering this. – Kjensen Oct 26 '19 at 15:46
  • Is it still a temporarily solution? – Guy P Jun 25 '20 at 05:55
  • 7 years later this saved my bacon with a RestSharp 105.2.3.0 vs 109.0.1.0 problem. ChatGPT claimed that just using 'null' in publicKeyToken field of the binding redirect would resolve the signed/unsigned issue but it was wrong, this solution was necessary. – Craig A Apr 19 '23 at 16:18