Making an Enum a Public Assembly member

I have an assembly, Shared, that contains an enum named MyEnum. I want to be able to define this enum once in the Shared assembly and then use it in other assemblies by referencing the Shared assembly. Is this possible I thought enums where managed types but I used the following code with no luck because it said that "an assembly access specifier can only be applied to a managed type" so I have to remove the public keyword.

namespace Shared
{
    public enum MyEnum
    {
       eEnumValue
    };
}

and then I reference it in another assembly:
#using "Shared.dll"

namespace App
{
    __gc class MyApp
    {
       Shared::MyEnum m_eMyEnum;
    }
}

this gives me an error that no MyEnum does not exist in the Shared namespace. Any help is appreciated, thanks -

Samy


Answer this question

Making an Enum a Public Assembly member

  • acraft

    That was the problem, thanks a lot -

    Samy

  • xuemingqiang

    You have to use the syntax for a managed enum. Try something like

    namespace Shared
    {
        public __value enum MyEnum
        {
           eEnumValue
        };
    }

    Bernd

  • Making an Enum a Public Assembly member