Deploy Microsoft.Bcl.Async with Clickonce

I have a VB.NET application crashing with the following error:

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'

I am trying to use the Microsoft.Bcl.Async library. I installed it through Nuget in a project that actually uses Async / Await calls and a project that references it. Everything works fine on my computer, but when I publish and test on another computer, my program crashes when I try to use part of it that uses Async / Await.

In System.Threading.Tasks, it is specified in both projects with Copy Local set to true. Microsoft.Threading.Tasks is mentioned in both projects with Copy Local set to true. I saw another thread about it, and it was installed in the respective projects. These are the lines contained in my app.config file:

  <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> 

What am I missing when setting up? Please let me know if you need more information. Thanks!

+6
source share
2 answers

I found a workaround posted on the project website:

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

Resolution

This is because ClickOnce cannot deploy certain required assemblies. As a workaround, do the following:

1. Right-click on the project and select Add Existing Item

2. Go to the package folder Microsoft.Bcl net40

3. In the "File Name" text box, enter.

4.Holding CTRL, select System.Runtime.dll and System.Threading.Tasks.dll

5. Click the down arrow next to the Add button and select Add As Link

6. In the Solution Explorer, while holding CTRL, select System.Runtime.dll and System.Threading.Taks.dll

7. Right-click the selection, select “Properties” and “Copy” to “Output Directory” to “Always Copy”

8.Republish

+9
source

Clicking once will only include the 3 core DLLs Microsoft.Threading.Tasks.dll , Microsoft.Threading.Tasks.Extensions.dll and Microsoft.Threading.Tasks.Extensions.Desktop.dll

enter image description here

However, there are several more DLLs that are two more dependencies that are added when the nuget package is added, which are not included in the redistributed System.Runtime.dll and System.Threading.Tasks.dll . You can see that the Path property for these two refrences is inside your project, and not in the usual place.

enter image description here

I'm not quite sure how to fix this, but at least now you know what the problem is.

+1
source

Source: https://habr.com/ru/post/952692/


All Articles