I published my project in debug mode and put both dll and pdb files in my server,
now i want to get exception line number using these codes :
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
Response.Write("Line: " + trace.GetFrame(0).GetFileLineNumber());
but i don't know why line number of exception is always zero -> 0
how can i fix it?
Try
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
var stackFrame = trace.GetFrame(trace.FrameCount - 1);
var lineNumber = stackFrame.GetFileLineNumber();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With