I have an exception handling attribute for the controller that writes error logs for every exception that comes in the program. I have .pdb file deployed on the server and have below code to written for the line numbers:
// Get stack trace for the exception with source file information
var st = new StackTrace(ex, true);
// Get the top stack frame
var frame = st.GetFrame(0);
// Get the line number from the stack frame
var line = frame.GetFileLineNumber();
Still I get line number as 0.
I have two questions on this:
- Shouldn't the line numbers get automatically written if I keep the .pdb file on the server?
- Why am I getting them as 0 in the above code?
Appreciate your reply.