How to invoke an event using Reflection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to invoke an event dynamically using Reflection. I can use
EventInfo.EventHandlerType to get the delegate type and from that delegate
type I can locate the "Invoke" member, but I cannot work out how to obtain
the instance of the delegate on which to call "Invoke".

I would have expected to find either an EventInfo.Invoke() member or
something like EventInfo.GetDelegate(object) to obtain the delegate instance,
but I cannot find anything.
 
On further thought, I assume that this is not actually possible. I had
forgotten that events cannot be invoked outside the declaring class, so
invocation using reflection would not make sense.
 
Robert said:
On further thought, I assume that this is not actually possible. I had
forgotten that events cannot be invoked outside the declaring class, so
invocation using reflection would not make sense.
 
Back
Top