Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
904 views
in Technique[技术] by (71.8m points)

visual studio 2010 - CLR/CLI linker fails with error LNK2022 - Custom attributes are not consistent

Environment: Visual Studio 10, CLR/CLI Class Library project, built with Platform Toolset v100, targeting framework version v3.5.

I am aware that this question was already asked here, but I did not find an answer that solved the problem for my case, so bringing this up again.

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 or less:

  • 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 or higher:

  • 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

How to define these values:

  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/>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...