Tagged: C++/CLI

Migrating a C++/CLI project from VS2008 to 2010

If you’ve recently migrated a mixed mode project to the VS2010 IDE then you might be experiencing the following errors – “Custom attributes are not consistent”.

It looks as though the conversion tries to readjust the project target to the 10.0 toolset. So first thing you need to do is change the toolset under the project settings to 9.0.

After compiling you’ll hit another roadblock with the targeted framework not existing. Since you can’t change the framework to .net 3.5 in the IDE you’ll need to unload the project, then right click and edit the .vcxproj file.

Add the <TargetFrameworkVersion> tag between the PropertyGroup tags, and reload the project to get your project building again

<PropertyGroup Label="Globals">

Note that one problem with this,is that you’ll have to add this additional line every time the project settings are updated.

Additionally you may hit a run-time snag, where the compiler gives a warning about the manifest being embedded after the assembly is signed.
The easy way around that issue is to delay sign the assembly and add a post build command of:
"$(DevEnvDir)..\..\sdk\v2.0\Bin\sn.exe" -q -Ra "$(TargetPath)" "$(ProjectDir)strongnamekey.snk"

That way the manifest will be embedded before the signing.

NB. vsprops are no longer used in VS2010. You’ll get the conversion to the new format, but you’ll manage the property pages via the property manager on a project-by-project basis.