我的C#应用程序引用了 AvalonWizard dll。 AvalonWizard dll使用 PublicKeyToken = 8f2c89e926618269 进行强签名。 但是,我的应用程序在加载 AvalonWizard dll时,试图使用 PublicKeyToken = null 加载程序集,因此出现以下错误:
FileLoadException:无法加载文件或程序集'AvalonWizard, PublicKeyToken = null”或其依赖项之一。位于 程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常:0x80131040)
我不明白为什么我的应用程序尝试使用公共密钥令牌null加载dll,因为在.csproj中引用了一个强签名的文件:
<Reference Include="AvalonWizard, Version=1.2.0.0, Culture=neutral, PublicKeyToken=8f2c89e926618269, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dlls\AvalonWizard.dll</HintPath>
</Reference>
我还检查了装配盲日志条目,这是结果:
*** Assembly Binder Log Entry (14/08/2018 @ 10:53:09) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Users\vicent.rico\Documents\GitHub\KNXPM\TestApp\bin\Debug\TestApp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = AvalonWizard, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Users/vicent.rico/Documents/GitHub/KNXPM/TestApp/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = TestApp.exe
Calling assembly : PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\vicent.rico\Documents\GitHub\KNXPM\TestApp\bin\Debug\TestApp.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\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:///C:/Users/vicent.rico/Documents/GitHub/KNXPM/TestApp/bin/Debug/AvalonWizard.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Users\vicent.rico\Documents\GitHub\KNXPM\TestApp\bin\Debug\AvalonWizard.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: AvalonWizard, Version=1.2.0.0, Culture=neutral, PublicKeyToken=8f2c89e926618269
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.
还有什么我可以检查的想法吗?我不明白的是为什么我的应用程序要寻找具有空公钥令牌的dll。