Wednesday, April 29, 2009

Function Name and Line Number in Visual Studio 2008

It is very helpful to log the function name and also the line number in a log file. Investigating the root cause of an exception or error requires knowing the problem area first. Function name and line number are narrow down the problem to a specific area which can save time and effort.

Here is the simple and convenient way to log the function name.

Environment.StackTrace.Split(Environment.NewLine.ToCharArray()))[4]

-Abhinaw

No comments:

Post a Comment