Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem creating COM-library only containing enum's
    text
    copied!<p>I'm am doing 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 ComVisible, they get exposed as Typelib.EnumType_EnumValue enstead of just Typelib.EnumValue. The typelib exporter does this to ensure that the value names are unique. But i know that all my enum's are unique, so i don't want the underscores. Also there is a lot of client code that needs alteration if i don't get rid of the underscores.</p> <p>To find a solution to this problem, i have defined the enum's in an IDL-file and creating a typelib and .Net interop from this. </p> <pre><code>[ 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; }; </code></pre> <p>I create a typelibrary with MIDL.exe which produces a tlb-file. </p> <p>And i create an assembly with the tlbimp.exe. signing the assembly with the same key as the other Interop assemblies.</p> <p>tlbimp OpenStructureAdapterEnum.tlb /keyfile:KeyFile.snk </p> <p>Then i register the assembly with regasm.exe This assembly looks fine and contains the enum without underscores. But the problem is that a can't see the COM-library from OLE/COM Object Viewer or from VBA or VB6. And when i reference the enum from another COM-exposed assembly, the part of the interface containing references to the enum, gets exposed as resticted methods.</p> <pre><code>[restricted] void Missing7(); [restricted] void Missing8(); [restricted] void Missing9(); [restricted] void Missing10(); </code></pre> <p>How can i create a COM library containing only enums (without underscores) and referencing these from other .net Interop assemblies?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload