Npgsql 和 System.Threading.Tasks.Extensions 之间 System.Runtime.CompilerServices.Unsafe 的冲突

Conflict for System.Runtime.CompilerServices.Unsafe between Npgsql and System.Threading.Tasks.Extensions

我已经下载了 EntityFramework6.Npgsql 6.4.0 nuget。 作为依赖,Npgsql 4.1.2 与 nuget 一起安装。

虽然运行代码,观察到以下错误:

=== Pre-bind state information === LOG: DisplayName = **System.Runtime.CompilerServices.Unsafe, Version=4.0.5.0**, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a  (Fully-specified) LOG: Appbase = file:///C:/Program Files (x86)/Agilent Technologies/Sample Scheduler for OpenLab/Bin/ LOG: Initial PrivatePath = NULL Calling assembly : Npgsql, Version=4.1.2.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7.
=== LOG: This bind starts in default load context. LOG: No application configuration file found. LOG: Using host configuration file:  LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: System.Runtime.CompilerServices.Unsafe, Version=4.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a LOG: Attempting download of new URL file:///C:/Program Files (x86)/X/Y/Bin/System.Runtime.CompilerServices.Unsafe.DLL. WRN: Comparing the assembly name resulted in the mismatch: Revision Number ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

为了解决这个问题,我已经将 System.Runtime.CompilerServices.Unsafe、Version=4.0.5.0 复制到我的 Bin 目录中。

在此之后,我得到以下错误:

=== Pre-bind state information === LOG: DisplayName = **System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1**, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a  (Fully-specified) LOG: Appbase = file:///C:/Program Files (x86)/Agilent Technologies/Sample Scheduler for OpenLab/Bin/ LOG: Initial PrivatePath = NULL Calling assembly : System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
=== LOG: This bind starts in default load context. LOG: No application configuration file found. LOG: Using host configuration file:  LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a LOG: Attempting download of new URL file:///C:/Program Files (x86)/X/Y/Bin/System.Runtime.CompilerServices.Unsafe.DLL. WRN: Comparing the assembly name resulted in the mismatch: Revision Number ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

由于不同版本对同一个库的不兼容依赖,我无法继续。

请帮忙解决这个问题。

根据@ShayRojansky 输入。 我在 app.config 文件中添加了绑定重定向。

我的应用程序有一个实体库,它将执行所有数据库操作。 我在我的 VS 中为这个实体库项目添加了 Nugets。

构建后,这些绑定重定向未添加到我的应用程序配置中。 我手动更新了 EXE。app.config 这个问题已经解决了。