Reflection Question
-
Hello everyone. I've been trying to find a way of figuring out how to know which method called another method. For now I'm using the MethodInfo MethodBase Object and passing it as a parameter to the called method but is there a better way of doing it? I know that you can find out who the calling assembly is, but how do I find out the name of the method that made the call? Thanks for any help.
-
Hello everyone. I've been trying to find a way of figuring out how to know which method called another method. For now I'm using the MethodInfo MethodBase Object and passing it as a parameter to the called method but is there a better way of doing it? I know that you can find out who the calling assembly is, but how do I find out the name of the method that made the call? Thanks for any help.
Look at my post regarding exactly how to do this, a few posts down (i think yesterday or the day before), on how to use StackTrace. From there u can get the MethodBase just as you want it, but be warned, it will likely be much slower than passing MethodBase.Current. Anyways, I dont find anything wrong with your approach as long as you keep those ugly ones private! ;p top secret xacc-ide 0.0.1
-
Look at my post regarding exactly how to do this, a few posts down (i think yesterday or the day before), on how to use StackTrace. From there u can get the MethodBase just as you want it, but be warned, it will likely be much slower than passing MethodBase.Current. Anyways, I dont find anything wrong with your approach as long as you keep those ugly ones private! ;p top secret xacc-ide 0.0.1
Thanks for your reply, I'll look into your suggestion. I don't see anything wrong with it either other than I'm lazy and don't want to have to create the methodbase object from each of the methods that calls that particular method, I'd rather have the called method figure it out. Again, thanks for your help.