问题
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>
回答1:
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>
来源:https://stackoverflow.com/questions/38834155/restsharp-error-when-shared-as-a-dependency-and-different-publickeytokens