在Visual Studio 2010 Beta 2中定位.NET 3.5 C++/CLI

jef*_*ora 3 .net c++-cli visual-studio-2010 visual-c++ c1001

有没有人成功将VS 2008 C++/CLI(vcproj)项目转换为VS 2010项目(vcxproj),同时将.NET 3.5作为目标框架?我无法做到这一点并让项目成功构建.该项目在VS2008中编译为.NET 3.5,在VS2010中编译为.NET 4.0,但我无法在2010年使用.NET 3.5.IDE似乎没有为它提供选项,并且修改了vcxproj文件通过增加

<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
Run Code Online (Sandbox Code Playgroud)

导致编译失败,并出现以下错误:

Error   1   error C1001: An internal error has occurred in the compiler.
Run Code Online (Sandbox Code Playgroud)

根据这个链接,在VS2008和2010之间使用的编译器显然存在一些差异,但仍然建议手动编辑项目文件作为解决方案.有没有人对此有任何想法?

Kev*_*hon 13

当您将.Net框架v3.5作为目标并使用VS2010构建时,由于VS2010在编译时会自动添加对System.Core的引用,因此有时会触发链接器错误C1001.这不是明确的,不会出现在您的引用中,而是在编译期间完成.您可以通过在Globals PropertyGroup中添加此元素来告诉VS不添加程序集:

<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
Run Code Online (Sandbox Code Playgroud)

  • 打开有关Microsoft Connect的错误报告:https://connect.microsoft.com/VisualStudio/feedback/details/560606/c1001-compiler-crash-on-c-cli-project-in-vs2010-when-target-framework-是-3-5 (2认同)