Microsoft.Threading.Tasks引用不正确的System.Threading.Tasks.dll版本
我正在使用.NET framework 4.0开发一个C#库。
在这个库上我安装了这些NuGet包:
这是我的App.config内容:
在这个项目中,我正在引用System.Threading.Tasks version 2.6.10.0
。 我已经创建了一个安装程序并将该项目安装在另一台计算机 我在安装程序上添加了System.Threading.Tasks version 2.6.10.0
(在GAC上安装此dll)。 但是,当我运行可执行文件时,我收到此错误:
Could not load file or assembly 'System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. at MyProject.Common.WebApi.Client.AsyncHelpers.c__DisplayClass7 1.b__6(Object _) at MyProject.Common.WebApi.Client.AsyncHelpers.ExclusiveSynchronizationContext.BeginMessageLoop() at MyProject.Common.WebApi.Client.AsyncHelpers.RunSync[T](Func 1 task) at MyProjectCodesManagerWindowsService.WebApi.Client.MyProjectCodesManagerClient.PrepareAndStartv2(String orderNumber, String userName, String systemName)
但在所有项目中我都引用System.Threading.Tasks version 2.6.10.0
。
为什么我得到这个例外? 任何建议?
我已经从这个页面https://blogs.msdn.microsoft.com/bclteam/p/asynctargetingpackkb/检查了所有问题,但结果相同。
在这个页面https://pauliom.com/2012/01/30/how-to-log-net-binding-errors-when-you-dont-have-fuslogvw-exe/之后 ,我得到了这个日志:
Calling assembly : Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. === LOG: Start binding of native image System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. WRN: No matching native image found.
问题出在Microsoft.Threading.Tasks, Version=1.0.12.0
它是System.Threading.Tasks版本= 1.5.11.0的依赖项。 我在文件夹D:packagesMicrosoft.Bcl.1.1.10libsl4
找到了dll。
使用程序.NET Reflector我已经看到Microsoft.Threading.Tasks, Version=1.0.12.0
与System.Threading.Tasks version=1.5.11.0
有依赖关系。
当我修改所有App.config文件以使用版本2.6.10.0时,为什么使用该DLL版本?
我找到了解决方案。
我必须补充一点:
进入程序的App.Config,它将使用我的库。
问题是我必须将我的库中的dependentAssembly添加到程序的app.config中,它将使用这个库。
我在这里找到了解决方案: https : //social.msdn.microsoft.com/Forums/en-US/f0653a7f-4196-4b5e-8d96-61d75fb8274e/gac-dll-and-appconfig?forum=clr
上述就是C#学习教程:Microsoft.Threading.Tasks引用不正确的System.Threading.Tasks.dll版本分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1030612.html