Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've found that if you are writing .Net Components for Consumption in VB6 (or any other COM environment) the utilisation of Interfaces is absolutely criticial.</p> <p>The COM templates that comes out of the box with VStudio leave a lot to be desired especially when you are trying to get Events to work.</p> <p>Here's what I've used.</p> <pre><code>Imports System.Runtime.InteropServices Imports System.ComponentModel &lt;InterfaceType(ComInterfaceType.InterfaceIsDual), Guid(ClientAction.InterfaceId)&gt; Public Interface IClientAction &lt;DispId(1), Description("Make the system raise the event")&gt; sub SendMessage(ByVal theMessage As String) End Interface &lt;InterfaceType(ComInterfaceType.InterfaceIsIDispatch), Guid(ClientAction.EventsId)&gt; Public Interface IClientActionEvents &lt;DispId(1)&gt; Sub TestEvent(ByVal sender As Object, ByVal e As PacketArrivedEventArgs) End Interface &lt;ComSourceInterfaces(GetType(IClientActionEvents)), Guid(ClientAction.ClassId), ClassInterface(ClassInterfaceType.None)&gt; _ Public Class ClientAction Implements IClientAction Public Delegate Sub TestEventDelegate(ByVal sender As Object, ByVal e As PacketArrivedEventArgs) Public Event TestEvent As TestEventDelegate public sub New() //Init etc end sub public sub SendMessage(theMessage as string) implements IClientAction.SendMessage onSendMessage(theMessage) end sub Protected Sub onSendMessage(message as string) If mRaiseEvents Then RaiseEvent TestEvent(Me, New PacketArrivedEventArgs(theMessage)) End If End Sub end Class </code></pre> <p>I've been able to get COM and .Net consumers of the Assembly/Component to work properly with events and be able to debug in and out of the component.</p> <p>Hope this helps.</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