The problem of creating a COM library containing only an enumeration

I am running a COM-interop project. Substituting some VB and C ++ ATL COM projects with C # and .NET Interop. When I define enumerations in .NET and they are made by ComVisible, they become available as Typelib.EnumType_EnumValue only for Typelib.EnumValue. The typelib exporter does this to ensure that value names are unique. But I know that all my enumerations are unique, so I do not want underlining. There is also a lot of client code that needs to be changed if I don't get rid of underscores.

To find a solution to this problem, I defined the enumeration in the IDL file and created a search between typelib and .Net between them.

[
  uuid(64893FD4-359D-46B9-BC1E-48C055796104),
  version(1.0),
  helpstring("ABC"),
  helpfile("AAA.chm"),
  helpcontext(0x00000001)
]

library EnumTypeLib
{
    importlib("stdole2.tlb");
    typedef [uuid(8FF85069-C4E2-4540-A277-4C0F3C19B807), helpstring("MyEnum"), helpcontext(0x00000066)]
    enum MyEnum {
        Value1 = 0,
        Value2 = 1,
    } MyEnum;
};

I am creating a typelibrary with MIDL.exe, which creates a tlb file.

tlbimp.exe. , Interop.

tlbimp OpenStructureAdapterEnum.tlb/keyfile:KeyFile.snk

regasm.exe . , COM- OLE/COM Object Viewer VBA VB6. , COM, , , .

[restricted] void Missing7();
[restricted] void Missing8();
[restricted] void Missing9();
[restricted] void Missing10();

COM, ( ) .net Interop?

+3
2

:

.NET COM PermissionControlLib :

public enum NetOperations
{
   Oper1,
   Oper2,
   Oper3
}

VB6 :

Public Enum VBOperations
   Oper1=NetOperations.NetOperations_Oper1,
   Oper2=NetOperations.NetOperations_Oper2,
   Oper3=NetOperations.NetOperations_Oper3
End Enum

:

Dim ud as PermissionControlLib.IUser
Set ud = New User
Dim b as Boolean
b = ud.HasPermissionInOperation(VbOperations.Oper1)
+1

. , , TypeLib, COM-. COM- , TypeLib - ( ). , COM. COM-, COM.

Microsoft , TypeLib . , . , COM-; - TypeLib.

- .NET. TlbImp.exe, , - . , . , .NET. TypeLib. .NET- , .

, . , .NET. COM. , , . , , .

0

All Articles