0

I am trying to build an application which I require it to be targetting .NET Framework v2.0. As you've probably told from the title, the language I am using is C++ .NET. For some reason, when I include Windows.h in stdafx.h, I get the following errors:

1>MSVCMRT.lib(mstartup.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0001e2). 1>MSVCMRT.lib(mstartup.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0001e6). 1>MSVCMRT.lib(managdeh.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000c0). 1>MSVCMRT.lib(managdeh.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000c2). 1>MSVCMRT.lib(mehvecdtr.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000a6). 1>MSVCMRT.lib(mehvecdtr.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000a9). 1>MSVCMRT.lib(ManagedMain.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000bf). 1>MSVCMRT.lib(ManagedMain.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000c1). 1>MSVCMRT.lib(msilexit.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000e9). 1>MSVCMRT.lib(msilexit.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000ec). 1>MSVCMRT.lib(pureMSILcode.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c000199). 1>MSVCMRT.lib(pureMSILcode.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c00019a). 1>LINK : fatal error LNK1255: link failed because of metadata errors

If I remove #include < Windows.h > the application compiles perfectly fine. It appears to be a problem with including the Windows.h header file for some reason. I am compiling using the /clr switch.

Any ideas? Thanks a lot!

Codehack
  • 323
  • 2
  • 13
  • These might be helpful, http://stackoverflow.com/questions/18571546/clr-cli-linker-fails-with-error-lnk2022-custom-attributes-are-not-consistent and http://stackoverflow.com/questions/7201904/how-to-use-stdafx-h-properly. – Baris Demiray Sep 04 '15 at 15:17
  • The question is moot, you cannot target 2.0 with VS2015. The resulting assembly will always have a reference to the .NET 4.0 version of mscorlib.dll. You must have VS2008 installed, then you can use the v9.0 toolset to build the program. – Hans Passant Sep 05 '15 at 14:48

0 Answers0