How to get the name of the method that caused the exception

Posted by SKumar on Stack Overflow See other posts from Stack Overflow or by SKumar
Published on 2011-01-04T20:48:40Z Indexed on 2011/01/04 20:53 UTC
Read the original article Hit count: 189

My code looks as below.

        try
        {
            _productRepo.GetAllProductCategories();
        }
        catch (Exception ex)
        {
            //Do Something
        }

I need a way to show the method name, suppose in the above case if any exception is thrown in the GetAllProductCategories() method, I need to get this method name i.e. "GetAllProductCategories()" as my result. Can any one suggest me how to do this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about exception-handling