Hi,
I have a .net class library which I want to expose to VB6. There is a public
enumeration in the .net namespace, and after com type library is created from
the .net dll, the enumeration elements end up having a prefix with the enum
name. I would like to know how to make the type library not to have any
prefixes.
Below is the .net code:
namespace TestInterop
{
[Guid("F6D522B3-0A0B-4f95-9966-E0D0AD5627F0")]
public interface IClass1
{
void EnumTest(SampleEnum pv_e);
}
[Guid("23F31309-93B0-4673-B9EF-232E8C7FB5C5")]
[ClassInterface(ClassInterfaceType.None)]
public class Class1: IClass1
{
public void EnumTest(SampleEnum pv_e)
{
;
}
}
public enum SampleEnum
{
orange = 1,
apple = 2
}
}
This is the OLE View of the com type library:
[
uuid(4F7AE37C-C405-4BCA-83C4-F67538AB08CC),
version(1.0)
]
library TestInterop
{
// TLib : // TLib : mscorlib.dll :
{BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}
importlib("mscorlib.tlb");
// TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
interface IClass1;
[
odl,
uuid(F6D522B3-0A0B-4F95-9966-E0D0AD5627F0),
version(1.0),
dual,
oleautomation,
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9},
"TestInterop.IClass1")
]
interface IClass1 : IDispatch {
[id(0x60020000)]
HRESULT EnumTest([in] SampleEnum pv_e);
};
[
uuid(23F31309-93B0-4673-B9EF-232E8C7FB5C5),
version(1.0),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "TestInterop.Class1")
]
coclass Class1 {
interface _Object;
[default] interface IClass1;
};
typedef [uuid(89162C26-B57A-3C33-A8DE-AE4812A44E1B), version(1.0) ,
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "TestInterop.SampleEnum")
]
enum {
SampleEnum_orange = 1,
SampleEnum_apple = 2
} SampleEnum;
};
I would like to know how to make the enum look like just orange and apple
instead of SampleEnum_orange and SampleEnum_apple.
I appreciate for any help you might have.
-- mk
Mattias Sjögren - 14 Nov 2006 21:48 GMT
>I would like to know how to make the type library not to have any
>prefixes.
There's no way to turn that off. So what you can do is create the
typelib manually in IDL instead of letting Tlbexp or Regasm generate
it for you. Then you have complete control over its contents.
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Kim - 14 Nov 2006 23:33 GMT
Hi Mattias,
Thank you for the reply. Would you guide me on creating the typelib manually
in IDL? This is a new area for me and I am not sure where to start. Links to
any online resources or web sites would help too.
Thank you in advance.
-- mk
Ramki - 20 Jun 2008 05:43 GMT
Hi ,
I want to know hot to register managed COM interop in winodws CE as COM
object.
I have Dll , whicis having inetrface and class like this.
namespace MagnumDevApp
{
[ComVisible(true)]
[Guid("C68CAF28-0DE2-4baf-BBD3-9066B8D7B3AF")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IComcls
{
int GetNum();
}
}
namespace MagnumDevApp
{
[ComVisible(true)]
[Guid("D7A01E18-8C49-4ede-96C9-99889B7AA2EF")]
[ClassInterface(ClassInterfaceType.None)]
public class comcls : IComcls
{
public comcls()
{
}
public int GetNum()
{
return 1;
}
}
}
i stuck with this. Its working fine in desktop .I need to call progID of
this dll in ASP file to create object.
REgards,
Rama
> Hi Mattias,
>
[quoted text clipped - 5 lines]
>
> -- mk