6

我有一个因以下错误而崩溃的 VB.NET 应用程序:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Threading.Tasks, Version=2.5.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. File name: 'System.Threading.Tasks, Version=2.5.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

我正在尝试使用 Microsoft.Bcl.Async 库。我已经通过 Nuget 在实际使用 Async/Await 调用的项目和引用它的项目上安装了它。一切都在我的计算机上完美运行,但是当我在另一台计算机上发布和测试时,当我尝试使用它使用 Async/Await 的部分时,我的程序崩溃了。

System.Threading.Tasks 在 Copy Local 设置为 true 的两个项目中都被引用。Microsoft.Threading.Tasks 在 Copy Local 设置为 true 的两个项目中都被引用。我已经看到有关此的另一个线程,它已安装在相关项目中。这些是我的 app.config 文件中包含的行:

  <dependentAssembly>
    <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.5.19.0" newVersion="2.5.19.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.5.19.0" newVersion="2.5.19.0" />
  </dependentAssembly>

设置这个我错过了什么?如果您需要更多信息,请告诉我。谢谢!

4

2 回答 2

9

我在项目网站上找到了一个解决方法:

http://blogs.msdn.com/b/bclteam/p/asynctargetingpackkb.aspx

解析度

这是因为 ClickOnce 无法部署某些必需的程序集。作为解决方法,请执行以下操作:

1.右键单击项目并选择添加现有项目

2.浏览到Microsoft.Bcl net40 包文件夹

3.在文件名文本框中输入

4.按住CTRL,选择System.Runtime.dll和System.Threading.Tasks.dll

5.单击添加按钮旁边的向下箭头,然后选择添加为链接

6.在解决方案资源管理器中,按住 CTRL 选择 System.Runtime.dll 和 System.Threading.Taks.dll

7.右键单击选择,选择属性并将复制到输出目录更改为始终复制

8.重新发布

于 2013-10-16T20:31:21.197 回答
1

单击一次将仅包含 3 个主要 DLL 的Microsoft.Threading.Tasks.dllMicrosoft.Threading.Tasks.Extensions.dllMicrosoft.Threading.Tasks.Extensions.Desktop.dll

在此处输入图像描述

但是,当您添加未包含在可分发包中的 nuget 包时,还有一些 DLL 是另外两个依赖项,System.Runtime.dllSystem.Threading.Tasks.dll可以看到这Path两个引用的属性在您的项目中,而不是在正常位置。

在此处输入图像描述

我不完全确定如何解决它,但至少现在您知道问题所在了。

于 2013-08-28T21:52:47.523 回答