Subject: Question: Dynamically Raise Event using Reflection API

  • Thread starter Thread starter Guest
  • Start date Start date
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!
 
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
 
Back
Top