使用Clickonce部署Microsoft.Bcl.Async

Cut*_*ert 6 .net vb.net asynchronous base-class-library

我有一个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的部分时,我的程序崩溃了.

在Copy Local设置为true的两个项目中引用System.Threading.Tasks.在Copy Local设置为true的两个项目中引用Microsoft.Threading.Tasks.我已经看到关于这个的另一个线程,它已安装在相关项目中.这些是我的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>
Run Code Online (Sandbox Code Playgroud)

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

Ran*_*dom 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.在Solution Explorer中,按住CTRL选择System.Runtime.dll和System.Threading.Taks.dll

7.右键单击所选内容,选择"属性",然后将"复制到输出目录"更改为"始终复制"

8.Republish


Sco*_*ain 1

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

在此输入图像描述

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

在此输入图像描述

我不完全确定如何解决它,但至少现在你知道问题是什么。