Monday, 17 October 2011

Headaches and Compiling C++ .NET 3.5 projects under VS2010

 

Background:

One of our partners released some open source components in the form of C++ assemblies, which we consume in our product. I needed to recompile one of them today. By opening the VC++ project in Visual Studio 2010, they were automatically upgraded to .NET 4.0. This is no good, as our product is currently running 3.5 and subsequently wouldn’t load the compiled assemblies.

So, I needed to make the assemblies compiled under 3.5 within VS2010. Turns out this isn’t as obvious as I was expecting.

Solution:

1. Open the ‘*.vcxproj’ file within a text editor.

2. Find the section titled ‘<PropertyGroup Label="Globals">’ and add in the following line within it:

<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>

3. Open the solution within VS2010 and right click –> ‘Properties’ on the project.

4. Click on the ‘Common Properties’ section and verify that it says ‘Version=v3.5’

image

5. Click on the ‘Configuration Properties’ section and change the ‘Platform Toolset’ to ‘v90’ (.NET 2.0/3.0/3.5)

If you get any errors when you build, you may need to verify that the C++ components are installed as part of your VS2008 (yes – 2008) installation. You can verify this by opening up ‘Programs and Features’ in Control Panel and click ‘Repair’ while focused on the VS2008 Team entry in the list.

No comments:

Post a Comment