How would I get a method name from the calling assembly?

  • Thread starter Thread starter kevingabbert
  • Start date Start date
K

kevingabbert

I was very happy to find:
System.Reflection.MethodBase.GetCurrentMethod.Name

however, I have an errorhandler in another dll, which means, when it is
called, I need to find out what function raised the error to begin
with. so far I have been using the above and passing it to the
errorhandler. However, I found this nice snippet:

System.Reflection.Assembly.GetCallingAssembly().GetName.Name

however, this code is wrong, but I would like to get the name of the
method that calls my errorhandler function. something that could look
like this:

System.Reflection.Assembly.GetCallingAssembly.MethodBase.GetCurrentMethod.Name

also if I was able to get it this way, would dotfuscator break it?

-Kevin Gabbert
 
Kevin,

take a look at the StackFrame class, which has this information.
however, the name of the callee is only available in debug
builds.

WM_HOPETHISHELPS
thomas woelfer
http://www.die.de/blog
 
Back
Top