Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Its too much to write in a comment, so I'll make it an answer....</p> <p>First, identify the .net class you want to expose to COM. I'll pick a class called CORE.</p> <p>Create an interface that describes the EVENTS that the CORE object will source (ie generate).</p> <pre><code>&lt;ComVisible(True)&gt; _ &lt;Guid("some guid here...use guidgen, I'll call it GUID1")&gt; _ &lt;InterfaceType(ComInterfaceType.InterfaceIsIDispatch)&gt; _ Public Interface ICoreEvents &lt;System.Runtime.InteropServices.DispId(1)&gt; _ Sub FileLoaded(ByVal Message As String) End Interface </code></pre> <p>Next, Create an interface for the COM exposed properties and methods of your class.</p> <pre><code>&lt;ComVisible(True)&gt; _ &lt;Guid("another GUID, I'll call it guid2")&gt; _ &lt;InterfaceType(ComInterfaceType.InterfaceIsDual)&gt; _ Public Interface ICore ReadOnly Property Property1() As Boolean ReadOnly Property AnotherProperty() As ISettings ReadOnly Property Name() As String ReadOnly Property Phone() As String End Interface </code></pre> <p>Now, create your actual .net class</p> <pre><code>&lt;ComVisible(True)&gt; _ &lt;ClassInterface(ClassInterfaceType.None)&gt; _ &lt;ComDefaultInterface(GetType(ICore))&gt; _ &lt;ComSourceInterfaces(GetType(ICoreEvents))&gt; _ &lt;Guid("a third GUID, I'll call it GUID3")&gt; _ Public Class Core Implements ICore &lt;System.Runtime.InteropServices.ComVisible(False)&gt; _ Public Delegate Sub OnFileLoaded(ByVal Message As String) Public Event FileLoaded As OnFileLoaded End Class </code></pre> <p>Now, when you need to raise the FileLoaded event, just RAISEEVENT FILELOADED(Message) from within your class. .NET will forward the event out to COM because you've hooked up the COMSourceInterfaces attribute.</p> <p>The attribute is shorthand for much of of this, but unfortunately doesn't give you quite the control that you need to do certain things (for instance retain version compatibility on your com interfaces).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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