Home All Groups Group Topic Archive Search About

Subject: Question: Dynamically Raise Event using Reflection API

Author
15 Jun 2006 8:30 AM
KIM
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!

--
KIM

Author
16 Jun 2006 12:30 AM
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


Show quote
"KIM" <K**@discussions.microsoft.com> wrote in message
news:C400917C-423B-4199-B71E-F8DCEF5C3A46@microsoft.com...
> 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!
>
> --
> KIM

AddThis Social Bookmark Button