如何在 Visual Studio 2017 中构建旧解决方案

问题描述 投票:0回答:1

我对引用

System.Net.Http
版本 2.0.0.0 的解决方案有疑问。该解决方案的项目全部针对 .NET 4.0,并且它们显然是在 Visual Studio 2012 中构建的。问题是当我尝试在 VS 2017 中构建它时,出现以下错误:

在“项目2”中:

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

在“项目1”中:

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"

我尝试使用 app.config 程序集绑定来更改引用的版本,但这似乎没有任何效果。关于 SO 的类似问题的其他建议已被考虑在内,但它们似乎大多涉及这些绑定。

<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>
.net visual-studio visual-studio-2012 visual-studio-2017
1个回答
0
投票

最终的解决方案是按照用户 drone6502 的评论中的建议安装 System.Net.Http nuget 包。

© www.soinside.com 2019 - 2024. All rights reserved.