Enum values in C++/CLI class Library are not visible in C# in VS2022

Nagaswathi Sadari 1 Reputation point
2022-06-24T15:28:50.97+00:00

In C++ we have a nested class, where we have an outer class and the inner enum class as Public (like below code snippet)

Using PlatformToolSet as V100(VS2010) we have generated C++ Dll and adding it as a reference in C# library. From the C# project using this reference, inner enum class values are visible in the object browser.

When we build the same code with PlatformToolSet as V143(VS2022) and use this C++/CLI dll as a reference in C# project, the inner enum class values are not visible in the object browser.

Added the snippet from C++/CLI class library where the DummyInner enum is visible but the values inside the DummyInner is not visible in the C#.

Code Snippet :
public class Dummy
{
public:
enum class DummyInner
{
None = 0,
EnumA,
EnumB,
EnumC,
EnumD,
EnumE
};
};

This issue happens only with VS2022 with V143 PlatformToolSet and the same code is working fine with the Vs2010 (V100) PlatformToolSet.

Please provide your suggestions.

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Microsoft Security | Microsoft Authenticator
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 125.7K Reputation points
    2022-07-08T07:43:40.293+00:00

    If the program works, maybe you can ignore this issue.

    To solve it, try adding ref:

    public ref class Dummy  
    {  
       . . .  
    }  
    
    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.