For logging purposes, some methods in our application include the following line:
Dim Log As ILog = GetLog(Reflection.MethodBase.GetCurrentMethod().Declaring
I just had the same question and found this answer, but maybe it is not up to date any more so I post my testresults...
I don't know about previous versions of the dot net Framework, but in dot net Framework 4 I get the following calling Times. So performance should not be an issue any more...
Here is the code which produced this output:
_txtReport.Text = string.Empty;
var sw = new Stopwatch();
sw.Start();
var type = MethodBase.GetCurrentMethod().DeclaringType;
sw.Stop();
_txtReport.Text += string.Format("First Call to MethodBase.GetCurrentMethod().DeclaringType: {0} ms - {1} ticks{2}",
sw.ElapsedMilliseconds, sw.ElapsedTicks, Environment.NewLine);
sw.Start();
var type1 = this.GetType();
sw.Stop();
_txtReport.Text += string.Format("First Call to this.GetType(): {0} ms - {1} ticks{2}",
sw.ElapsedMilliseconds, sw.ElapsedTicks, Environment.NewLine);