Managed C++ and Visual Studio 2008/2010

For people who write Managed C++ code (C++ code that take advantage of .NET and loads into the CLR), you may want to hang onto your Visual Studio 2008 install even when installing Visual Studio 2010. This is because when a pre-2010 Visual Studio C++ project file (vcproj) is updated to 2010 project file (vcxproj) it automatically “targets” .NET 4.0. This is ignored for unmanaged C++ projects, but for managed C++ projects it means that you can only exist on a system with .NET 4.0 installed. .NET 4.0 is not ubiquitous yet, so I don’t recommend targeting it.

To target .NET 3.5 for your Managed C++ code you actually have to hand-edit the project file. This isn’t hard, just follow the instructions here as posted on stackoverflow.

The kicker is that while C# and VB.NET projects can target any version from 2.0 of the .NET framework and greater with just the tools provided by the .NET Framework, C++ code, managed or unmanaged, needs tools only shipped with the appropriate version of VS. This means that when you target .NET 3.5 for your managed C++ code, even when building with VS 2010, it requires VS 2008 to be installed so the appropriate linker, manifest generator, etc. binaries are installed.

REMEMBER, this issue only affects managed C++ code. Even though unmanaged C++ projects say they target the .NET 4.0 Framework, it is of no consequence.

Hope this helps!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s