How to specify .NET version when using / CLR

I am compiling third-party C ++ code using the / CLR flag, which only requires the .NET Framework 3.5.

The code compiles in order, but since I have .NET 4.0 installed on my dev block, the resulting binary does not work for any .NET platform less than 4.0

So, how can I tell Visual Studio to use a specific version of the .NET Framework when compiling?

+7
source share
1 answer

Quote from a Visual C ++ article by Team Blog , Visual Studio 2010 C ++ Project Upgrade Guide :

... VS2010 compiler cannot target Framework 2.0, 3.0 or 3.5. The VS2008 compiler should be used for targeting 2.0, 3.0 or 3.5 .... C ++ applications can be redirected to other frameworks (for example, for example 3.5) in one of the following ways:

  • Edit the vcxproj file and in the first group of properties define add the following: <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
  • Open the VS2010 command line, set TargetFrameworkVersion=v3.5 , and then run the devenv.exe file from the command line. This will target all your C ++ applications within v3.5 framework.
  • Pass /p:TargetFrameworkVersion=v3.5 to MSBuild when creating applications: MSBuild my.vcxproj /p:TargetFrameworkVersion=v3.5

Please note that VS2008 must be installed on the computer so that the application is intended for 2.0, 3.0 or 3.5.

+8
source

All Articles