To help save time on my wrapper and to make sure it was correct I found that AxImp.exe will create a wrapper for a dll. At the same time you can have it output the code it uses as C#. I converted it using an online converter. For the moment I'll assume that all of that was done correctly. The problem is that none of the events were working. Here is the example of the AfterConnect code it created.
The Sub AfterConnect1 that Implements AfterConnect gets hit, but unless in that even I use the sub AfterConnect the Project that uses this will never fire off the AfterConnect event. Once that line is in then everything works fine. Is this the correct use of Implements with Events or has something got messed up in all of the translation?
-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
Code:
Namespace AxObjectXAS400Display
Public Class AxObjectXAS400Display
Inherits System.Windows.Forms.AxHost
Private eventMulticaster As AxObjectXAS400DisplayEventMulticaster
Public Event AfterConnect As IObjectXAS400DisplayEvents_AfterConnectEventHandler
Friend Sub RaiseOnAfterConnect(ByVal sender As Object, ByVal e As IObjectXAS400DisplayEvents_AfterConnectEvent)
RaiseEvent AfterConnect(sender, e)
End Sub
End Class
Public Class AxObjectXAS400DisplayEventMulticaster
Public Delegate Sub IObjectXAS400DisplayEvents_AfterConnectEventHandler(ByVal sender As Object, ByVal e As IObjectXAS400DisplayEvents_AfterConnectEvent)
Public Class IObjectXAS400DisplayEvents_AfterConnectEvent
Public success As Integer
Public Sub New(ByVal success As Integer)
Me.success = success
End Sub
End Class
Public Overridable Sub AfterConnect(ByVal success As Integer)
Dim afterconnectEvent As New IObjectXAS400DisplayEvents_AfterConnectEvent(success)
Me.parent.RaiseOnAfterConnect(Me.parent, afterconnectEvent)
End Sub
Public Sub AfterConnect1(ByVal Success As Integer) Implements ObjectXAS400Display.IObjectXAS400DisplayEvents.AfterConnect
[red]AfterConnect(Success)[/red] [green]'I added as it didn't do anything until I did. I don't know if this is correct or not though.[/green]
End Sub
End Class
End Namespace
-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!