C++/CLI enum not showing up in C# with reference to C++/CLI project

心不动则不痛 提交于 2019-12-22 03:19:29

问题


I can't get the contents of an C++/CLI enum to show up in a C# project.

I can see inside a class I wrote, and even see the enum, but I can't see the enum values. So I can't use the thing on my C# side.

Any reason why contents of a C++/CLI enum wouldn't show up.

My C++/CLI project is compiled as mixed to reuse a C++ library.

And I'm using Visual Studio 2005.


回答1:


Make sure you used enum class to create a .NET-compatible enumeration, and not a native C++ enum type.

Later versions of Visual C++ require public enum class, to disambiguate from the enum class contextual keyword which is part of C++11 (and therefore creates a native type).



来源:https://stackoverflow.com/questions/7031439/c-cli-enum-not-showing-up-in-c-sharp-with-reference-to-c-cli-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!