Aug 272013
 

LNK2022? 

You will stumble upon this error if you are migrating your C++/CLI project from Visual Studio 2010 to Visual Studio 2012.

error LNK2022: metadata operation failed (801311E4) : Duplicate managed types have different visibilities

Cause for LNK2022? 

One scenario for this error is when you are setting a different visibility for a native element and another include file has already set another visibility. Something like…

#include <anotherinclude.h>
#pragma make_public(g_SomeNativeType)

Here you are trying to override a visibility set in ‘anotherinclude.h’ via make_public macro hence you see the linker error ‘duplicate managed types have different visibilities’. This code used to compile fine in Visual Studio 2010 but errors out in Visual Studio 2012.

Resolution for LNK2022?

This is a bug and it is fixed via hotfix: KB2848798.

Relevant detail from above hotfix link…

LNK2022

Leave a Reply