我有以下代码。
以上代码的最后一行提示以下错误:
我仍然收到相同的运行时错误,它抱怨没有找到Extensions 4.2.0.0。我错过了什么?
var factory = new ConnectionFactory()
{
HostName = "path.to.host.net",
UserName = "guest",
Password = "guest",
VirtualHost = "myhost"
};
var connection = factory.CreateConnection();
以上代码的最后一行提示以下错误:
我检查了Fusion日志,结果如下:FileLoadException: 无法加载文件或程序集'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'或其某个依赖项。所定位的程序集清单定义与程序集引用不匹配。(HRESULT 异常:0x80131040)
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\IIS Express\iisexpress.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
(Fully-specified)
LOG: Appbase = file:///C:/Path/To/Web/
LOG: Initial PrivatePath = C:\Path\To\\Web\bin
Calling assembly : System.Threading.Channels, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Path\To\Web\web.config
LOG: Using host configuration file: C:\Users\fahadash\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: Attempting download of new URL file:///C:/Users/fahadash/AppData/Local/Temp/Temporary ASP.NET Files/vs/699f3d52/97d4d2c/System.Threading.Tasks.Extensions.DLL.
LOG: Attempting download of new URL file:///C:/Users/fahadash/AppData/Local/Temp/Temporary ASP.NET Files/vs/699f3d52/97d4d2c/System.Threading.Tasks.Extensions/System.Threading.Tasks.Extensions.DLL.
LOG: Attempting download of new URL file:///C:/Path/To/Web/bin/System.Threading.Tasks.Extensions.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
我在IL反汇编器中打开了bin
文件夹中的DLL,并检查了清单,发现如下信息:
System.Threading.Tasks.Extensions.DLL 版本为 4.2.0.1。 该版本依赖于 System.Runtime.CompilerServices.Unsafe 4.0.4.1,而此版本已经存在于 bin 文件夹中。
因此,由于 4.2.0.0 与 4.2.0.1 不匹配,我决定添加以下绑定重定向:
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
我仍然收到相同的运行时错误,它抱怨没有找到Extensions 4.2.0.0。我错过了什么?