Connecting Tech Pros Worldwide Forums | Help | Site Map

EventInfo.GetRaiseMethod() always returns null

Sergio Geralnik
Guest
 
Posts: n/a
#1: Nov 22 '05
I am trying to use this method to get a MethodInfo object
but the method always returns a null.
See my sample code below:

this.button1 = new System.Windows.Forms.Button();
this.button1.Click += new System.EventHandler
(this.button1_Click);

private void button1_Click(object sender, System.EventArgs
e)
{
EventInfo eventInfo = (sender as Button).GetType().GetEvent
("Click");

// This line always results in raiseMethod being null
MethodInfo raiseMethod = eventInfo.GetRaiseMethod();

}

Thanks for any help.

Mattias Sjögren
Guest
 
Posts: n/a
#2: Nov 22 '05

re: EventInfo.GetRaiseMethod() always returns null


Sergio,
[color=blue]
>I am trying to use this method to get a MethodInfo object
>but the method always returns a null.[/color]

I don't know which method's MethodInfo you want to retrieve, but
events generated by the C# compiler (or VB.NET) never have a raise
method associated with them (it's optional) so that's why
GetRaiseMethod always will return null for those events.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Closed Thread


Similar .NET Framework bytes