RestSharp error when shared as a dependency and different publicKeyTokens
Asked Answered
K

1

13

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>
Krawczyk answered 8/8, 2016 at 16:22 Comment(0)
K
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>
Krawczyk answered 8/8, 2016 at 17:3 Comment(5)
Seems kinda nutty that at this stage of the game we're reduced to playing these games straight outta 90's DLL Hell.Pragmatics
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.Krawczyk
For me it was the HelloSign API triggering this.Mf
Is it still a temporarily solution?Almaalmaata
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.Burch

© 2022 - 2024 — McMap. All rights reserved.