本文介绍了CLR / CLI链接器失败,错误LNK2022 - 自定义属性不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:
使用平台工具集构建的Visual Studio 10,CLR / CLI类库 v100

我知道这个问题

在构建一个的时候,我已经在这里问了一个问题,但是没有找到解决问题的答案。 CLR / CLI类库(DLL)项目链接器失败时出现以下错误:

While building a CLR/CLI Class Library (DLL) project the linker is failing with the following errors:

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


推荐答案

我在路上学到的另一件事是你不能混合 Platform Toolset 目标框架的值版本

Another thing I learned on the way is that you cannot mix values of Platform Toolset and Target Framework Version.

我发现的可能组合位于:

The possible combinations I found where:

。 NET 3.5或更低版本:


  • Platform Toolset v90 ,将使用 Visual Studio 2008 运行时二进制文件,

  • TargetFrameworkVersion v3.5 (或更少),

  • 在预处理器中,您可以拥有 _WIN32_WINNT (例如 _WIN32_WINNT = 0x0500

  • Platform Toolset: v90, which will use Visual Studio 2008 runtime binaries,
  • TargetFrameworkVersion: v3.5 (or less),
  • In the preprocessor you can have _WIN32_WINNT defined (e.g. _WIN32_WINNT=0x0500)

.NET 4.0

.NET 4.0 or higher:


  • strong>,它将使用 Visual Studio 2010 运行时二进制文件,

  • TargetFrameworkVersion v4.0 (或更高版本)

  • 在预处理器中不能定义_WIN32_WINNT = 0x0500 li>
  • Platform Toolset: v100, which will use Visual Studio 2010 runtime binaries,
  • TargetFrameworkVersion: v4.0 (or higher),
  • In the preprocessor you must not have the '_WIN32_WINNT=0x0500' defined

如何定义这些值


  1. 平台工具集 - 找到它:项目设置|

  2. TargetFrameworkVersion - 卸载项目,右键单击卸载的项目,然后选择编辑。打开*。* proj文件后,修改以下行:< TargetFrameworkVersion> v3.5< TargetFrameworkVersion />

  1. Platform Toolset – find it under: Project settings | General,
  2. TargetFrameworkVersion - Unload the project, right-click on the unloaded project and select 'Edit'. Once the '*.*proj' file is open, modify the following line: <TargetFrameworkVersion>v3.5<TargetFrameworkVersion/>

这篇关于CLR / CLI链接器失败,错误LNK2022 - 自定义属性不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 01:29