views:

1491

answers:

3

Since I upgraded my project to visual studio 2010 project format, my C++/CLI project is targeted to .net framework 4.0.

It is easy to switch the framework version to another version from a C# project, but I have no clue how to do this in a C++/CLI project, I see no setting for this in the project property pages.

+3  A: 

Yes it is possible to change the target even for managed C++ projects:

Changing the Target .NET Framework for C++/CLI (VS 2010) To change the version of the .NET Framework for C++/CLI projects (VS 2010)

Right click on project in Solution Explorer and click Unload project Right click on unloaded project in Solution Explorer and select Edit .vcxproj In project XML file locate node In that node locate node (if the node cannot be found, add it) Inner text of the node defines target framework. It can be v2.0,v3.0, v3.5 or v4.0 Save vcxproj file and close it Right click on unloaded project in Solution Explorer and click Reload Project Example v3.5

Note: These steps apply only for Visual Studio 2010 as it uses new format of C++ project files.

Source on MSDN: How to: Change the Target .NET Framework

Brian R. Bondy
I now did these steps but now I get the error "MSB8009: .NET Framework 2.0/3.0/3.5 target the v90 platform toolset. Please make sure that Visual Studio 2008 is installed on the machine". I do not have VS2008.
codymanix
+5  A: 

This shows up when you press F1 in the Framework and References dialog:

By default for new projects, the targeted framework is set to .NET Framework 4. The IDE does not support modifying the targeted framework, but you can change it manually. In the project file (.vcxproj), the default targeted framework is represented by the v4.0 property element. To change the targeted framework, unload the project, use a text editor to open the project file, and then change the value of the property element from v4.0 to another version that is installed on your server. For example, if you specify v3.5, which represents the .NET Framework v3.5, Visual Studio 2008 SP1 must be installed. Save and close the file, reload the project, and verify that the targeted framework is displayed in the property page.

That's not terribly accurate on converted projects, you'll have to add the <TargetFrameworkVersion> element yourself. Put it in the PropertyGroup labeled "Globals":

  <PropertyGroup Label="Globals">
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    <others...>
  </PropertyGroup>
Hans Passant
I now did these steps but now I get the error "MSB8009: .NET Framework 2.0/3.0/3.5 target the v90 platform toolset. Please make sure that Visual Studio 2008 is installed on the machine". I do not have VS2008.
codymanix
Quote from my answer: *"Visual Studio 2008 SP1 must be installed".* You are missing the required build tools.
Hans Passant
A: 

I'm in the exact same situation: VS 2008 is not installed on my machine so I cannot target .NET Framework v3.5 in a C++ project that doesn't use .NET at all! Did you find any solution since May 27th?

SBorum
Your situation is different, you said that your project is not .NET and this question is about C++/CLI (.NET). So ask your own question.
Ben Voigt