Why doesn't the publication publish System.Net.Http.dll?

I have a WPF application written in C # that cannot publish System.Net.Http.dll and System.Net.Http.WebRequest.dll.

When the user starts the application, he receives an error:

Could not load file or assembly 'System.Net.Http, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file.

To repeat this problem:

  • Open VS2012
  • File -> Create -> Project -> Visual C # -> WPF Application
  • Right Click Links -> NuGet Package Management ...
  • Add Microsoft ASP.NET Web API Client Libraries by searching Microsoft.AspNet.WebApi.Client
  • Right click project -> Properties
  • Click the Publish tab
  • Uncheck Automatically increase revision with each publication
  • Click Publish Now
  • Note that in the publish\Application Files\WpfApplication1_1_0_0_0 you will see System.Net.Http.Formatting.dll.deploy, but you will not see the other two files: System.Net.Http.dll.deploy or System.Net. Http.WebRequest.dll.deploy.
+4
source share
1 answer

Work around


Currently, I have included binaries in the root of the project. It smells, but will have to be done until a better solution appears.

Workarounds:

  • Right click on the project -> Add ... -> Existing item
  • Go to SolutionRoot\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40 and select both the System.Net.Http.dll and System.Net.Http.WebRequest.dll files
  • This adds both files as β€œContent” to the application - you will receive warnings ( MSBuild Error MSB3178 ), but it does not appear, it can do something about it
  • Please note that now, when you publish, both files will be in the publish\Application Files\WpfApplication1_1_0_0_0
+5
source

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


All Articles