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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interop back to COM and Events. 1

Status
Not open for further replies.

mmilan

Programmer
Jan 22, 2002
839
GB
Afternoon everyone...

I'm writing a class in VB2005, and I want to expose various methods and events back to a VB6 client.

The approach I've taken is to define an interface for the properties and methods of my class - and then implemented this interface using my class. Additionally, I've created an Interface for the Events my class exposes, and implemented those with my class as well...

If my class uses the <ComClass()> attribute, my methods and properties are exposed to COM. If it uses the <COMSourceInterfaces()> attribute to point to the Events interface, the events are exposed to COM, but the methods aren't. I seems I can't use both interfaces...

I have noticed that I can use one of the overloaded constructos of the <ComClass()> attribute to set up my interfaces using their GUIDs, but these have to be constants. This causes me problems, owing to the way my employer does things in terms of releasing versions.

Anyone got any ideas?

Martin.
 
I let vb.net make mine. The code it created and works for me is:

Code:
<ComClass(comClassName.ClassId, comClassName.InterfaceId, comClassName.EventsID)
Public Class comCalssName

#Region "COM GUIDs"
    Public Const ClassId As String = "<insert id>"
    Public Const InterfaceId As String = "<insert id>"
    Public Const EventsId As String = "<insert id>"
#End Region

Replace the <insert id> with the id numbers for your Class, Interface, and Event.

-I hate Microsoft!
-Forever and always forward.
 
Thanks for that - I did try that approach and had trouble with it.

In the end, I wrote myself a really simple example, and found I could get it working just with ComClass() (Default constructor)

Now the real fun begins!

Have a star...
 
Thanks, good luck, and have fun. :)

-I hate Microsoft!
-Forever and always forward.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top