Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C# Component for VB6 application

Status
Not open for further replies.

JCruz063

Programmer
Joined
Feb 21, 2003
Messages
716
Location
US
Hi gang,
Can anybody tell me how to go about creating a code component (e.g. a class) to be used by a VB6 application?

Thanks

JC

 
By the way (in case you ask), I intend to write the code component in C#, to be used in a VB6 app.

JC

 
HI JC

As this is Interop between the managed and unmanaged worlds this is not entirely straight forward. There are a number of steps you'd need to follow to achieve this.

First up create your component in C# and register it to the Global Assembly Cache using the gacutil command line tool

Next define a COM Interface for the component, register this also.

Next create a COM Adapter for the component which implements the COM Interface.

Implement the COM Interface in your component.

Deploy the COM Adapter by regsitering to the GAC and generating a COM type library using the regasm command line tool.

Finally add the reference to the COM Adapter in your VB6 project.

There is a fair bit of documentation on this but havign only done this in training exercises rather than real world development I can't provide much more than theory.

Hope this gets you started though...

Rob


Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
Thanks Rob,
Do you know where such documentation is?

Thanks again!

JC

 
I have attempted to create a C# class that exposes a couple of public members to a COM client. Although the VB6 client can call the methods and properties of the .NET server and the code executes properly, there is no intellisense in VB 6 for the class (making it difficult to use).

I have tried to use regasm with the tlb option and tlbexp. Is there something else?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top