Groups | Blog | Home
all groups > dotnet interop > july 2003 >

dotnet interop : How do you structure a .net component to be used in VB6 environment?


Patrick Blackman
7/29/2003 9:29:03 PM
Can anyone tell me how to properly structure a .net component to be used in
VB6 . I have a small component which I want to export to a tlb file but when
ever I do the export, all the events are not available in VB6. Any help
would be appreciated.

Dennis Doomen
8/6/2003 3:55:12 PM
Hi Patrick,

Typically, you choose how you want to export your .NET classes to VB6
(through COM's IDispatch mechanism). You can either export all public class
members by applying the ClassInterfaceAttribute to your class and selecting
AutoDispatch for the ClassInterfaceType property.
The other solution (and also the best in terms of good design), is to create
an interface that contains the methods, etc you want to expose, and
implement that interface in your class. You then apply the
InterfaceTypeAttribute to the interface, and ClassInterfaceAtribute
(ClassInterfaceType.None) to the class. This ensures, that only the
interface is visible from VB6/COM. Make sure you pass the proper settings to
the InterfaceTypeAttribute to ensure it exposes the interface through
IDispatch.

Dennis Doomen
Sioux TSO Netherlands

[quoted text, click to view]

AddThis Social Bookmark Button