Reputation: 42175
I'd like to get the fully qualified method name. I can see how to get the method name on its own with the following:
System.Reflection.MethodBase.GetCurrentMethod().Name
but this only returns the actual name. I need everything, like:
My.Assembly.ClassName.MethodName
Upvotes: 43
Views: 21175
Reputation: 4423
You probably want the GetCurrentMethod().DeclaringType, which returns a Type object that holds information about the class which declares the method. Then you can use FullName property to get the namespace.
var currentMethod = System.Reflection.MethodBase.GetCurrentMethod();
var fullMethodName = currentMethod.DeclaringType.FullName + "." + currentMethod.Name;
Upvotes: 23
Reputation: 33260
Try
var methodInfo = System.Reflection.MethodBase.GetCurrentMethod();
var fullName = methodInfo.DeclaringType.FullName + "." + methodInfo.Name;
Upvotes: 60