How can I expose a .NET enum name to COM in the same naming convention as legacy C++ COM components?

72 Views Asked by At

I have a legacy C++ component with enums which can be accessed to COM clients. For example:

typedef [v1_enum] [uuid(C04A9760-3555-1555-9555-0DA024B80555)]
[helpstring("Enum in C++")] 
enum myEnumName
{
    [helpstring("First Value")]     
        myEnumNameFirstValue
}

The COM client imports the library using its LIBID (guid) and can then use this enum as:

myEnumNameFirstValue

But if you defined this same enum in C#

enum myEnumName
{
   FirstValue
}

COM clients would refer to this as:

myEnumName_FirstValue

And .NET clients would refer to this as:

myEnumName.FirstValue

Thing is.. I'm trying to build a .NET component to "trick" COM clients into using it as if it's the legacy C++ component. And though I can create classes and methods that these clients "fall for", I can't do it with enums!

Is there any way to define an enum in .NET and override the exposed COM name? i.e. instead of name_value it exposes namevalue?

0

There are 0 best solutions below