How to invoke an event using Reflection

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.
 
G

Guest

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.
 
T

Tim Bassett

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.
 

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