简体   繁体   English

无法在Visual Studio 2015中定位.Net 2.0

[英]Cannot target .Net 2.0 in Visual Studio 2015

I have a project that targets both .Net 2.0 and .Net 4.5. 我有一个针对.Net 2.0和.Net 4.5的项目。 I built+published it successfully in Visual Studio 2013. The .Net configuration in the .csproj file still says 我在Visual Studio 2013中成功发布了它。在.csproj文件中的.Net配置仍然说

<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>

Yet, when I open the project in VS 2015, it targets .Net 4.5. 然而,当我在VS 2015中打开项目时,它的目标是.Net 4.5。

I have 2.0 available in the Target Framework dropdown: 我在Target Framework下拉列表中有2.0可用:

目标框架下拉列表

when I click ".Net Framework 2.0" it gives me a popup saying 当我点击“.Net Framework 2.0”时,它给了我一个弹出窗口

你确定吗?

Changing the target framework requires that the current project be closed and then reopened. 更改目标框架需要关闭当前项目,然后重新打开。
Any unsaved changes within the project will be automatically saved. 项目中任何未保存的更改都将自动保存。

Changing Target Framework my require manual modification of project files in order to build. 更改目标框架我需要手动修改项目文件才能构建。

Are you sure you want to change the Target Framework for this project? 您确定要更改此项目的目标框架吗?

When I click yes, the target framework goes back to 4.5 and nothing else happens. 当我单击是时,目标框架将返回到4.5并且不会发生任何其他情况。

  • I've tried reopening the project and VS, with no luck. 我试过重新打开这个项目和VS,没有运气。
  • I've tried running the .Net 3.5 installer (which apparently includes 2.0) , but it says I need to use "Turn Windows Features on/off" 我试过运行.Net 3.5安装程序(显然包含2.0) ,但它说我需要使用“打开/关闭Windows功能”
    • I've ensured the .Net 3.5 Windows Feature is enabled. 我确保启用.Net 3.5 Windows功能。

And now I'm out of ideas. 现在我没有想法了。 Has anyone else encountered this? 有人遇到过这种情况么?

Running Windows 7. 运行Windows 7。

In case, the .NET Framework 2.0 is corrupted, use the .NET Framework setup verification tool: https://blogs.msdn.microsoft.com/astebner/2013/11/06/net-framework-setup-verification-tool-and-cleanup-tool-now-support-net-framework-4-5-1/ to verify and once it found any corrupted, you can use the .NET Framework Repair Tool: https://www.microsoft.com/en-us/download/details.aspx?id=30135 to repair it. 如果.NET Framework 2.0已损坏,请使用.NET Framework安装验证工具: https//blogs.msdn.microsoft.com/astebner/2013/11/06/net-framework-setup-verification-tool- and-cleanup-tool-now-support-net-framework-4-5-1 /验证,一旦发现任何损坏,您可以使用.NET Framework修复工具: https//www.microsoft.com/en -us / download / details.aspx?id = 30135来修复它。

Or under 'Turn Windows Features on or off', uncheck .NET Framework 3.5 (includes .NET 2.0 and 3.0), then check it. 或者在“打开或关闭Windows功能”下,取消选中.NET Framework 3.5(包括.NET 2.0和3.0),然后检查它。

As Hans Passant mentions in the comments, I apparently(?) edited the .csproj to use different frameworks for different configurations. 正如Hans Passant在评论中提到的那样,我显然(?)编辑了.csproj,以便为不同的配置使用不同的框架。 I swear this didn't cause any issues in VS 2013. 发誓这并没有引起VS 2013的任何问题。

But in any case, I verified using ILSpy that the .dll being generated is .Net 2.0, even though the dropdown says 4.5. 但无论如何,我使用ILSpy验证了生成的.dll是.Net 2.0,即使下拉列表显示为4.5。 So I guess all's well that ends well? 所以我觉得一切都很顺利?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM