C# - get line number which threw exception -


in catch block, how can line number threw exception?

if need line number more formatted stack trace exception.stacktrace, can use stacktrace class:

try {     throw new exception(); } catch (exception ex) {     // stack trace exception source file information     var st = new stacktrace(ex, true);     // top stack frame     var frame = st.getframe(0);     // line number stack frame     var line = frame.getfilelinenumber(); } 

note work if there pdb file available assembly.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -