3

所以,我知道有很多类似的问题,但是在过去的一天里我已经倾注了很多答案,但没有任何帮助。

我正在开发一个引用一堆外部 DLL 的 WPF 应用程序。特别是有一个DLL,称为DefinitionInterpreter,它已被证明会引起麻烦。在我引用它的每个项目中,它都很固执,选择不工作。我能够让它在我的单元测试套件中工作,但是,我不能尽我所能,让它在我的 WPF 应用程序中工作。

我已经尝试过 GAC,清理我的项目,添加和删除它,重新启动,检查版本,检查依赖关系,但没有任何效果。

我不断收到同样的异常:

无法加载文件或程序集“DefinitionInterpreter,Version=3.6.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(来自 HRESULT 的异常:0x80131040)

我尝试在 ildasm.exe 中打开 DLL,但没有显示任何异常。它的唯一依赖项是 System.Xml、System.Core 和 mscorlib。

当我检查清单时,它会验证版本是 3.6.0.0

真正让我感动的是它在我的一个项目中工作,但我无法让它在另一个项目中工作,即使它们引用相同的 DLL(相同的路径和所有内容)。

有什么建议么?我正在使用 .NET 4.0(项目要求它是 4.0)并且已经尝试过 x86 和 x64。

编辑:

查看 Fusion Log 详细信息后,我得到以下输出:

*** Assembly Binder Log Entry  (7/18/2013 @ 7:07:42 PM) ***

The operation failed.
Bind result: hr = 0x80131040. No description available.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  E:\Src\Hermes\Tool\bin\Debug\HermesClient.vshost.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = DefinitionInterpreter, Version=3.6.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///E:/Src/Hermes/Tool/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = HermesClient.vshost.exe
Calling assembly : SomeAssembly, Version=13.5.13.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\Src\Hermes\Tool\bin\Debug\HermesClient.vshost.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///E:/Src/Hermes/Tool/bin/Debug/DefinitionInterpreter.DLL.
LOG: Assembly download was successful. Attempting setup of file: E:\Src\Hermes\Tool\bin\Debug\DefinitionInterpreter.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: DefinitionInterpreter, Version=3.6.0.0, Culture=neutral, PublicKeyToken=75a99a2a5bcd4c96
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

我的 CSProj 中的参考如下:

    <Reference Include="DefinitionInterpreter, Version=3.6.0.0, Culture=neutral, PublicKeyToken=75a99a2a5bcd4c96, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\DefinitionInterpreter.dll</HintPath>
      <Private>True</Private>
    </Reference>

当我执行命令时,sn -T DefinitionInterpreter.dll我得到 75a99a2a5bcd4c96。老实说,我不知道在运行时它如何认为公钥令牌为空以及为什么不匹配。

4

1 回答 1

2

因此,从日志看来,“SomeAssembly”链接到该 DLL 的未签名版本,但所有本地版本都已签名。

如果您自己构建“SomeAssembly” - 检查对“DefinitionInterpreter”的引用是否指向签名版本,否则仔细检查 ILDasm 是否“SomeAssembly”确实是指非签名版本并要求所有者提供另一个版本。

于 2013-07-19T05:20:37.507 回答