A
AngryGerbil
hey,
How do I acquire MethodInfo WITHOUT hardcoding method name as a
string?!??!The fact I have to use xxx.Gettype.GetMethod("MyMethod",
xxx) is making me want to drive an ice pick into my eye!
I have exhausted my resources and I cannot find a way out of it.
Having to use that creates a dangerous situation because the name of
the method could change. For instance, let's say you fav 3rd party
library rolls out a new version and the hardcoded strings won't match
it. Then you have to go through your code and hope to God you nail
them all or an exception will be thrown. Thats bad for huge production
code bases with hundreds of thousands of lines of code spread out all
over the place.
I need something, (anything!), like this:
==================
public sub MyMethod()
....do something
end sub
dim oInfo as methodInfo
oInfo = xxxxx.GetType.GetMethod(xxxxx.GetType.GetMethodName(MyMethod))
==================
Does somebody out there know something I don't? In Delphi....all I had
to do was "Somevar := @MyMethod" and I had what I needed. Of course, I
know thats bad bad in VB.NET, but some call that returns the string
name will work because I can then use the GetMethod without being
locked to a hardcoded method name. Any ideas? I'm desperate!
-The Angry Gerbil
(who wouldn't be angry if he could figure this out!)
How do I acquire MethodInfo WITHOUT hardcoding method name as a
string?!??!The fact I have to use xxx.Gettype.GetMethod("MyMethod",
xxx) is making me want to drive an ice pick into my eye!
I have exhausted my resources and I cannot find a way out of it.
Having to use that creates a dangerous situation because the name of
the method could change. For instance, let's say you fav 3rd party
library rolls out a new version and the hardcoded strings won't match
it. Then you have to go through your code and hope to God you nail
them all or an exception will be thrown. Thats bad for huge production
code bases with hundreds of thousands of lines of code spread out all
over the place.
I need something, (anything!), like this:
==================
public sub MyMethod()
....do something
end sub
dim oInfo as methodInfo
oInfo = xxxxx.GetType.GetMethod(xxxxx.GetType.GetMethodName(MyMethod))
==================
Does somebody out there know something I don't? In Delphi....all I had
to do was "Somevar := @MyMethod" and I had what I needed. Of course, I
know thats bad bad in VB.NET, but some call that returns the string
name will work because I can then use the GetMethod without being
locked to a hardcoded method name. Any ideas? I'm desperate!
-The Angry Gerbil
(who wouldn't be angry if he could figure this out!)