5

I have a situation where Docusign API is referencing the RestSharp signed assembly with a public key token of 598062e77f915f75. In the same project I am using the Twilio API which also references the unsigned Restsharp assembly, obviously with a null public key token.

I can make one or the other work but not both at the same time since I can't add both the signed and unsigned RestSharp references since they both have the same name.

When I have a reference to the signed assembly, the Docusign part works but the Twilio code errors with this:

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)

When I reference the unsigned assembly, Docusign errors with this:

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

Is there any way around this?

I have tried binding redirects in every combination I can think of:

  <dependentAssembly>
    <assemblyIdentity name="RestSharp" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="105.2.3.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="RestSharp" publicKeyToken="598062e77f915f75" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="105.2.3.0" />
  </dependentAssembly>
ericdc
  • 11,217
  • 4
  • 26
  • 34

3 Answers3

0

I can think of few possible ways to solve this issue:

  1. Binding redirect. Works if assemblies have same public key, otherwise you need to specify code base. See SO answer: Referencing 2 different versions of log4net in the same solution
  2. Using GAC. Not sure if it would work with unsigned assembly.
  3. Making use of AppDomain.AssemblyResolve event (see How to use Assembly Binding Redirection to ignore revision and build numbers)
  4. Signing / unsigning assembly with one key using ildasm.

I once had similar issue with different log4net versions being referenced by our project and 3rd party library. Here is a blog post.

Community
  • 1
  • 1
Andriy Buday
  • 1,959
  • 1
  • 17
  • 40
0

I was facing the same issue. I have used the Nuget package of RestSharpSigned. This resolved my issue.

Abhay Dhar
  • 131
  • 11
-1

Try to redirect every version up to the current to the latest installed version:

  <dependentAssembly>
    <assemblyIdentity name="RestSharp" publicKeyToken="598062e77f915f75" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-105.2.3.0" newVersion="105.2.3.0" />
  </dependentAssembly>
zodo
  • 57
  • 5