Solved 2008 detect current sub name

Posted on 2009-02-24
Last Modified: 2013-11-26
i need to write an event log. how to know what is the current sub routine name??
Question by:aarontham
    LVL 53

    Expert Comment

    You can use Reflection:

    LVL 53

    Accepted Solution

    System.Reflection.MethodBase.GetCurrentMethod().Name yields current method name.

    System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.FullName yields fullyqualified name of the method's class

    System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name yields method's class name without Namespace

    System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Namespace yield namespace
    LVL 19

    Expert Comment


    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now