gpt4 book ai didi

c# - 强命名程序集和未签名程序集

转载 作者:太空狗 更新时间:2023-10-29 23:53:21 26 4
gpt4 key购买 nike

我遇到这样一种情况,Docusign API 正在引用带有公钥 token 598062e77f915f75 的 RestSharp 签名程序集。在同一个项目中,我使用的是 Twilio API,它也引用了未签名的 Restsharp 程序集,显然带有空公钥 token 。

我可以使一个或另一个起作用,但不能同时起作用,因为我不能同时添加已签名和未签名的 RestSharp 引用,因为它们具有相同的名称。

当我引用已签名的程序集时,Docusign 部分有效,但 Twilio 代码出现以下错误:

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)

当我引用未签名的程序集时,Docusign 错误:

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)

有什么办法解决这个问题吗?

我已经尝试过在我能想到的每一种组合中绑定(bind)重定向:

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

最佳答案

我能想到几种可能的方法来解决这个问题:

  1. 绑定(bind)重定向。如果程序集具有相同的公钥,则有效,否则您需要指定代码库。请参阅 SO 答案:Referencing 2 different versions of log4net in the same solution
  2. 使用 GAC。不确定它是否适用于未签名的程序集。
  3. 利用 AppDomain.AssemblyResolve 事件(参见 How to use Assembly Binding Redirection to ignore revision and build numbers)
  4. 使用 ildasm 对程序集进行签名/取消签名

我曾经遇到过类似的问题,我们的项目和第 3 方库引用了不同的 log4net 版本。这是一个blog post .

关于c# - 强命名程序集和未签名程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37847033/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com