• About Nibu

bits and bytes

Best ever free blog on: C, C++, VC++, .net, Debugging, Memory Dump analysis, Windbg/CDB, Visual Studio, SharePoint and PowerShell
  • About Nibu

Error LNK2022 : metadata operation failed (80131195) : Custom attributes are not consistent

 .net, Visual C++ Compiler  No Responses »
Sep 192014
 

Issue Definition: LNK2022 

Customer migrated a project from VS2008/VS2010 to VS2012/VS2013. On compilation he get’s the following error: error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent.

Cause for LNK2022 

On checking project properties we saw that the platform toolset was set to V120 and the target framework version was set to v3.5. This is basically an untested and unsupported combination. When this combination is set the linker will error out mostly with below message…

Error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent

Resolution for LNK2022

v120 requires a compatible .net framework version: For example, to target the .NET Framework 4.5, you must use a compatible platform toolset such as Visual Studio 2013 (v120) or Visual Studio 2012 (v110).

How to change <TargetFrameworkVersion>
  1. In Visual Studio, in Solution Explorer, open the shortcut menu for your project and then choose Unload project. This unloads the project (.vcxproj) file for your project…
    LNK2022
  2. Open the shortcut menu for the project again…
    LNK2022
  3. Select “Edit ProjectName.vcxproj”.
  4. In the project file, locate the entry for the target Framework version. For example, if your project is designed to use the .NET Framework 4.5, locate <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> in the <PropertyGroup Label=”Globals”> element of the <Project> element.
    <PropertyGroup Label=”Globals”>
    <ProjectGuid>{FC41C62B-4B0E-4357-B913-251F12FE4DCD}</ProjectGuid>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <Keyword>Win32Proj</Keyword>
    <RootNamespace>ConsoleApplication2</RootNamespace>
    </PropertyGroup>
    <Import Project=”$(VCTargetsPath)\Microsoft.Cpp.Default.props” />
    <PropertyGroup Condition=”‘$(Configuration)|$(Platform)’==’Debug|Win32′” Label=”Configuration”>
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v120</PlatformToolset>
    <CharacterSet>Unicode</CharacterSet>
    <CLRSupport>true</CLRSupport>
    </PropertyGroup>
  5. Save the project file, File->Save or use shortcut Ctrl + S.
  6. In the solution explorer right click on the project file again and select the option “Reload Project” as shown below…LNK2022
    Say yes to below prompt…
    LNK2022
  7. Now your framework version will be set to v4.5. You can verify this via Project Property Dialog box…
    LNK2022
  8. Verified!

References

How to: Modify the Target Framework and Platform Toolset
Visual Studio 2013 Compatibility
.NET Framework SDKs and Targeting Packs for Visual Studio 2013
C++ Native Multi-Targeting

 Posted by Nibu Thomas at 6:09 pm  Tagged with: 80131195, Custom attributes, LNK2022, metadata, TargetFrameworkVersion, Visual studio, VS2008, VS2010, VS2012, VS2013

Recent Posts

  • SQL: Column metadata query
  • PowerShell: Working with System.Security.Claims.ClaimsIdentity to manage user identity
  • ActiveDirectory: PowerShell script to translate a Windows SecurityIdentifier (SIDs) to UserNames using System.Security.Principal.SecurityIdentifier.Translate
  • SharePoint: Find an SPFeature by DisplayName
  • PowerShell TidBits: Creating Excel Workbook and filling out data into WorkSheets

Tags

.net ActiveX ATL CComboBox CDialog Clipboard COM Console API Console Application cout CreateProcess CString Debug Debugger Debugging dumpbin Feature pack GDI Interview questions MVP MVP Summit MVP Summit 2008 Nibu Nibu babu thomas Nibu Thomas PowerShell Ray Ozzie Redmond SetBkMode SetWindowPos Sharepoint ShGetFileInfo Steve Ballmer stl Summit VC8 vector Visual studio Visual Studio 2013 VS2005 VS2008 VS2013 windbg Windows Windows Phone

Follow Me

RSS YouTube Facebook Twitter Google+

Subscribe to this blog

RSS Feed RSS - Posts

RSS Feed RSS - Comments

Donate

View Nibu Thomas's profile on LinkedIn
Subscribe

Visitors

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 99 other subscribers

Articles

  • About Nibu
  • MFC Feature Pack Tutorial – Part 1 – Getting started
  • MFC Feature Pack Tutorial – Part 2 – CMFCPropertySheet
  • MFC Feature Pack Tutorial – Part 3 – CMFCPropertyGridCtrl
  • What’s new in Visual Studio 2012 Solution Explorer
© 2012 bits and bytes Suffusion theme by Sayontan Sinha