B
bob meyering
I am using VB.NET. I have two assemblies, I am trying to raise an
event in one of them and have it received in the other. Below is some
pseudo code to illustrate what I am doing:
Assembly 1:
-------------------
Class myEventSourceClass
public event xyz()
sub myEventSource()
raiseevent xyz()
end sub
end class
Assembly 2 (I add a reference to Assembly 1)
--------------------------------------------
class form1
dim withevents myEventReceiver as new myEventSourceClass
sub myEventReceiver () handles myEventReceiver.xyz
msgbox("fired")
end sub
end class
When I call myEventSource-sub in assembly 1, the event is raised
without error. The problem is, assembly 2 "fired" never appears (which
is running as a modeless form). What am I missing? Something like this
however works (all within the same assembly):
Module Module1
Dim WithEvents p As New test
Class test
Public Event UOMChanged()
Public Sub r()
RaiseEvent UOMChanged()
End Sub
End Class
Sub Main()
p.r()
End Sub
Private Sub p_UOMChanged() Handles p.UOMChanged
MsgBox("event proc fired")
End Sub
End Module
event in one of them and have it received in the other. Below is some
pseudo code to illustrate what I am doing:
Assembly 1:
-------------------
Class myEventSourceClass
public event xyz()
sub myEventSource()
raiseevent xyz()
end sub
end class
Assembly 2 (I add a reference to Assembly 1)
--------------------------------------------
class form1
dim withevents myEventReceiver as new myEventSourceClass
sub myEventReceiver () handles myEventReceiver.xyz
msgbox("fired")
end sub
end class
When I call myEventSource-sub in assembly 1, the event is raised
without error. The problem is, assembly 2 "fired" never appears (which
is running as a modeless form). What am I missing? Something like this
however works (all within the same assembly):
Module Module1
Dim WithEvents p As New test
Class test
Public Event UOMChanged()
Public Sub r()
RaiseEvent UOMChanged()
End Sub
End Class
Sub Main()
p.r()
End Sub
Private Sub p_UOMChanged() Handles p.UOMChanged
MsgBox("event proc fired")
End Sub
End Module