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.

Microsoft Authenticator
Microsoft Authenticator
A Microsoft app for iOS and Android devices that enables authentication with two-factor verification, phone sign-in, and code generation.
5,554 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,632 questions
C#
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.
10,294 questions
C++
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.
3,541 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 112.5K 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.