visual studio如何修改c++项目的.net framework框架版本

本文详细介绍了如何在Visual Studio环境中修改项目文件(.vcxproj)和.props文件,确保它们与.NET框架版本一致。通过调整<TargetFrameworkVersion>元素,实现了平台工具集与.NET框架版本的正确匹配,确保了项目的正确编译和运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、 修改项目文件

  1. 在 Visual Studio 的“解决方案资源管理器”中,打开项目的快捷菜单,然后选择“卸载项目”。 这将为你的项目卸载项目文件 (.vcxproj)。

  2. 在菜单栏上,依次选择“文件”、“打开”、“文件”。 “打开文件”对话框中,导航到项目文件夹,然后打开项目文件 (.vcxproj)。

  3. 在项目文件中,找到目标 Framework 版本的条目。 例如,如果你的项目设计为使用 .NET Framework 4.5, <PropertyGroup Label="Globals">元素中找到 请在<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> 元素, 如果 <TargetFrameworkVersion> 元素不存在,则新增之,并修改相应版本号。

 二、修改.props文件,使工具集与.net框架匹配

Another thing I learned on the way is that you cannot mix values of Platform Toolset and Target Framework Version.

The possible combinations I found where:

.NET 3.5 or less:

  • Platform Toolsetv90, which will use Visual Studio 2008 runtime binaries,
  • TargetFrameworkVersionv3.5 (or less),
  • In the preprocessor you can have _WIN32_WINNT defined (e.g. _WIN32_WINNT=0x0500)

.NET 4.0 or higher:

  • Platform Toolsetv100, which will use Visual Studio 2010 runtime binaries,
  • TargetFrameworkVersionv4.0 (or higher),
  • In the preprocessor you must not have the '_WIN32_WINNT=0x0500' defined

 

 

参见:

1.https://msdn.microsoft.com/zh-cn/library/Ff770576.aspx

2.http://stackoverflow.com/questions/18571546/clr-cli-linker-fails-with-error-lnk2022-custom-attributes-are-not-consistent

转载于:https://www.cnblogs.com/erentec/p/4886083.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值