CLR/CLI链接器失败,错误LNK2022 - 自定义属性不一致

Paz*_*azO 14 clr preprocessor c++-cli visual-studio-2010

环境: Visual Studio 10, CLR/CLI Class Library项目,构建Platform Toolset v100,目标框架版本v3.5.

我知道这个问题已经在这里被问到了,但是我没有找到解决问题的答案,所以再次提起这个问题.

在构建CLR/CLI Class Library (DLL)项目时,链接器失败并出现以下错误:

MSVCMRT.lib(managdeh.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000f7).
MSVCMRT.lib(managdeh.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000fb).
MSVCMRT.lib(msilexit.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c000128).
MSVCMRT.lib(msilexit.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c00012c).
MSVCMRT.lib(puremsilcode.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000ee).
MSVCMRT.lib(puremsilcode.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000f1).
LINK : fatal error LNK1255: link failed because of metadata errors
Run Code Online (Sandbox Code Playgroud)

Paz*_*azO 39

我在路上学到的另一件事是,你不能混用值的Platform Toolset和Target Framework Version.

我找到的可能组合在哪里:

.NET 3.5或更低版本:

  • Platform Toolset:v90,它将使用Visual Studio 2008运行时二进制文件,
  • TargetFrameworkVersion:v3.5(或更少),
  • 在预处理器中,您可以_WIN32_WINNT定义(例如_WIN32_WINNT=0x0500)

.NET 4.0或更高版本:

  • Platform Toolset:v100,它将使用Visual Studio 2010运行时二进制文件,
  • TargetFrameworkVersion:v4.0(或更高版本),
  • 在预处理器中,您不能定义'_WIN32_WINNT = 0x0500'

如何定义这些值:

  1. Platform Toolset - 找到它:项目设置| 一般,
  2. TargetFrameworkVersion - 卸载项目,右键单击卸载的项目,然后选择"编辑".打开'*.*proj'文件后,修改以下行:<TargetFrameworkVersion>v3.5<TargetFrameworkVersion/>