所以,我知道有很多类似的问题,但是在过去的一天里,我浏览了许多答案,但没有任何帮助。
我正在开发一个引用了许多外部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(这是一个项目要求),并尝试了x86和x64。
编辑:
查看Fusion Log详细信息后,我得到以下输出:
我的CSProj文件中的引用如下:
我正在开发一个引用了许多外部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(这是一个项目要求),并尝试了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。我真的不知道为什么在运行时它认为公钥令牌是空的,以及为什么存在不匹配。