c# - 作为依赖项和不同的 publicKeyTokens 共享时的 RestSharp 错误

标签 c# asp.net .net docusignapi restsharp

使用来自 DocusignTwilioAuth0 的 API。所有 3 个都将 RestSharp.dll 作为依赖项。

如果我使用 Docusign 包中包含的 RestSharp.dllDocusign 运行良好,但 Auth0Twillio 给出错误:

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

如果我使用普通的 RestSharp.dll (Install-Package RestSharp),TwilioAuth0 工作正常,但我在使用文档签名:

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

添加绑定(bind)重定向并不能解决问题。没有绑定(bind)重定向,我在日志中收到此错误:

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

如果我使用绑定(bind)重定向:

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

绑定(bind)重定向代码:

<dependentAssembly>
    <assemblyIdentity name="RestSharp" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-105.2.3.0" newVersion="105.2.3.0" />
 </dependentAssembly>

最佳答案

通过将 Docusign 包中包含的 RestSharp.dll 重命名为“RestSharpDocusign.dll”并将其复制到我的项目中,暂时解决了这个问题。

我修改了程序集绑定(bind),以便在调用版本 100.0.0.0 时加载特殊的“RestSharpDocusign.dll”以及所需的 publicKeyToken Docusign。其他任何东西都会使用带有空 publicKeyToken 的标准 RestSharp.dll。

<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>

关于c# - 作为依赖项和不同的 publicKeyTokens 共享时的 RestSharp 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38834155/

相关文章:

c# - 如何返回一个空的 ReadOnlyCollection

asp.net - Microsoft.VisualBasic.Financial.Rate 错误, "Cannot calculate rate using the arguments provided"

c# - 简单的控制台应用程序测试

c# - 如何在回发后维护 Tab 键顺序

c# - 如何判断在使用 System.CommandLine 时是否指定了一个选项?

asp.net - IE7 中的 DropDownList BackColor

.net - WPF 应用程序的默认字体系列是什么?

.net - 如何添加一个集合,例如动态数组作为自定义 asp.net 控件的属性?

C# : Pass string array to c++ dll/dylib

asp.net - 在 .aspx 页面上引发 404