How to raiseevent across .NET assembly boundary using VB.NET

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
 
C

Carl Daniel [VC++ MVP]

You might want to post your question to a VB.NET newsgroup - this is a C++
newsgroup.

Try microsoft.public.dotnet.languages.vb instead.

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top