Search code examples
.netvisual-studiovisual-studio-2012visual-studio-2017

how to build an old solution in visual studio 2017


I have an issue with a solution that has a reference to System.Net.Http version 2.0.0.0. The solution's projects are all targeted to .NET 4.0 and they apparently build in Visual Studio 2012. The problem is when I try to build it in VS 2017, I get the following errors:

In "Project2":

Error   CS0006  Metadata file 'C:\Development\Project1.dll' could not be found

In "Project1":

The primary reference "Internal.Library" could not be resolved because it
has an indirect dependency on the framework assembly "System.Net.Http,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could
not be resolved in the currently targeted framework. 
".NETFramework,Version=v4.0". To resolve this problem, either remove the
reference "Internal.Library" or retarget your application to a framework
version which contains "System.Net.Http, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"

I have tried to use app.config assembly bindings to change the version being referenced, but this didn't appear to have any effect. Other suggestions for similar questions on SO have been taken into account but they mostly appear to involve these bindings.

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a"/>
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Solution

  • Ultimately the solution was to install the System.Net.Http nuget package as suggested in a comment by user drone6502.