Target .NET 3.5 C++/CLI in Visual Studio 2010 Beta

2019-02-15 14:04发布

问题:

Has anyone had any success converting a VS 2008 C++/CLI (vcproj) project to a VS 2010 project (vcxproj), whilst maintaining .NET 3.5 as the target framework? I haven't been able to do this and get the project to build successfully. The project compiles fine in VS2008 as .NET 3.5, and fine in VS2010 as .NET 4.0, but I am unable to target .NET 3.5 in 2010. The IDE doesn't seem to provide an option for it, and modifying the vcxproj file by adding

<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>

causes compilation to fail with the folling error:

Error   1   error C1001: An internal error has occurred in the compiler.

According to this link, there is apparently some differences in compilers used between VS2008 and 2010, but manually editing the project file was still suggested as a solution. Does anyone have any idea on this?

回答1:

Thanks for the tip on TargetFrameworkVersion. It worked for me, but this unfortunately does not help you.

It is easy to get "internal compiler error" if you have some old files (PCH files, object files) made for another version of the C++ compiler lying around. Have you cleaned everything when you changed tools version?



回答2:

When you're targeting .Net framework v3.5 and building using VS2010 you can sometimes trigger the linker error C1001 due to VS2010 automatically adding a reference to System.Core when you're compiling. This isn't explicit and will not show up in your references but rather done during compile time. You can tell VS to not add the assemblies by adding this element in your Globals PropertyGroup:

<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>


回答3:

Wow, the response to Brickner's bug report is devastating - targeting 3.5 is not supported and won't be fixed!

My own weird experiences with crashes are that they were fixed by turning on precompiled headers, even more strange because stdafx.h was empty so I don't know what they are doing.



回答4:

Install this hotfix and your troubles are probably gone: http://support.microsoft.com/kb/976656