CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Location
    Bangalore
    Posts
    53

    Access managed C++ public enum class from C# by Dynamically loading

    I have an managed C++ dll lib. It has claas info like below

    namespace tests
    {

    public enum class clours
    {
    Start = 0;
    Red = 1;
    Green = 2;
    Blue = 3;
    End = 4;
    }
    }

    I have written a client application in C# and load the dll dynamically(I am using reflection). I want to access the enum members and values between 'Start' and 'End' from the client application.

  2. #2
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: Access managed C++ public enum class from C# by Dynamically loading

    Quote Originally Posted by mjvalan View Post
    I have written a client application in C# and load the dll dynamically(I am using reflection). I want to access the enum members and values between 'Start' and 'End' from the client application.
    The enumeration seems well defined. You should be able to access it from your C# application. Are facing any problem in particular?

  3. #3
    Join Date
    Apr 2007
    Location
    Florida
    Posts
    403

    Re: Access managed C++ public enum class from C# by Dynamically loading

    Multiple issues I see...

    1) public enum class clours - can't have class and enum on the same declaration
    2) You need to use commas to separate each enum index, not semicolons.

    ie:

    Code:
    namespace Tests
    {
      enum Colors
      {
         Start,
         Red,
         Green,
         Blue,
         End,
      }
    }

  4. #4
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: Access managed C++ public enum class from C# by Dynamically loading

    Good spot mariocatch! I didn't notice that at all. I wonder if mjvalan typed it directly in codeguru...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured