TLBEXP enum export & name mangling

S

ssamuel

I'm trying to create a drop-in replacement for an existing COM library
in C# 2.0. The original library is unmanaged and my consumers are
customers' VB6 legacy apps, many of which rely on global constants. As
..NET doesn't allow global constants, and I have no member name control
over enums, I'm having problems emitting IDL with constants the VB will
consume without extensive code modification. A C# enum that looks like
this:

namespace MyNS
{
public enum MyEnum
{
ValueOne = 1,
ValueTwo = 2
}
}

gives me this IDL in the DLL and through tlbexp.exe:

typedef [uuid(...), version(1.0), custom({...}, "MyNS.MyEnum")]
enum {
MyEnum_ValueOne = 0,
MyEnum_ValueTwo = 1
} MyEnum;

The COM export docs on MSDN clearly state this is by design to prevent
name collision. My legacy apps are looking for ValueOne, and they're
not finding it because I'm emitting MyEnum_ValueOne.

Has anyone solved this problem?

Thanks,

Stephan
 
D

Dave Sexton

Hi Stephan,

Try adding the System.Runtime.CompilerServices.ScopelessEnumAttribute to your
enum definition.
 
S

ssamuel

Dave,

Thanks, but it didn't change the exported TLB file. It looks like that
only has an effect on unmanaged C++ consumers.

Stephan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top