Subject: Question: Dynamically Raise Event using Reflection API

G

Guest

Hi there,

I tried to find a way to dynamically raise event using Reflection API. The
scenario is, I have to raise a event in a class instance by using a given
event name. I can use the GetEvent(...) method of the Reflection API to get
the EventInfo object. However, the GetRaiseMethod of the EventInfo object is
always null. And I haven't found another way other than this to dynamically
raise an event of a .NET class.

Have anyone ideas about how to do it? Any help is greatly appreciated!
 
N

Noah Stein

I've recently been reflecting on methods in a class, and I believe I saw
some methods with names like raise_XXXX. Try using
GetMethods(BindingFlags.Instance|BindingFlags.NonPublic) on your type.
Unfortunately, I don't have things set up at the moment to quickly
double-check that for you.


-- Noah
 

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