How to add handlers to events for a late-bound object?
Posted on 2006-07-11
I have a .NET dll which is being referenced in a VB.NET application.
I'm referencing this object using late binding as we want the application to cope if the dll is missing from the run directory. This will happen in certain cases as not everyone who runs the application will need or have access to the dll. Please don't tell me to just give everyone the dll, that's not what we want.
The problem is that one of the objects I referencing from the dll raises a few events which I want to handle in the application.
I've defined the object variable like so:
Private m_objOptions As Object
and I'm initialising it like so:
m_objOptions = New Compass.clGetOptions()
I'm trying to add a handler to one of the events like so:
AddHandler m_objOptions.Status, AddressOf Message
but I'm getting the error
'Status' is not an event of 'System.Object'
Can anyone help me resolve this?
How do I add a handler to a late-bound object?