LNK2022(重复管理的类型有不同的可见性)的MSVS 2012 [英] LNK2022 (Duplicate managed types have different visibilities) on MSVS 2012

查看:257
本文介绍了LNK2022(重复管理的类型有不同的可见性)的MSVS 2012的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我移植从MSVS2005解决MSVS2012。该项目是在C ++。NET,但使用自制的本地C ++ libraires了。我们有没有问题,2005年建设的项目,但现在,我无法用建2012年,我得到了以下错误消息的一个项目:

I'm porting a solution from MSVS2005 to MSVS2012. The projects are in C++ .NET but use homemade native C++ libraires too. We had no problem building the projects with 2005 but now, I'm unable to build a project using 2012. I get the following error message:

MyFile.obj:错误LNK2022:元数据操作失败(801311E4):重复管理的类型有不同的可见性

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

这是什么意思?你需要我帮什么信息?

What does this mean? What info do you need to help me?

感谢您的帮助?

推荐答案

我发现的bug。这是一切的组合,已建议在这里。

I found the bug. It is a mix of everything that has been suggested here.

某处在该项目中,原生的C ++头文件包含。一类在这个文件与公开:

Somewhere in the project, a native C++ header file is included. A class in this file is made public with:

#include "File_Where_ClassName_Is_Defined.h"
#pragma make_public( ClassName )

但在我自己的code,我包括本身包括该公开的类中定义的报头的第二头。所以,在这一点上,这个类是在一个文件中公开,并在同一个项目的另一个文件的不可以公之于众。在复制与不同的可见性来自那里。

But in my own code, I include a second header that itself includes the header where the made public class is defined. So, at this point, the class is "made public" in one file and "not made public" in another file in the same project. The "duplicate with different visibilities" comes from there.

这是送我在错误的道路上唯一的一点是错误消息:重复管理的类型有不同的可见性。但在这里,它是一个非托管类型。

The only point that sent me on the wrong path was the error message: "Duplicate managed types have different visibilities". But here, it is an unmanaged type.

所以,如果你遇到这个错误有一天,寻找一个的#pragma make_public(...)的项目,然后找了重复列入你的问题的文件。

So, if you encounter this error someday, look for a #pragma make_public(...) in the project then look for a duplicated inclusion in your problematic file.

这篇关于LNK2022(重复管理的类型有不同的可见性)的MSVS 2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆