c# - How to get line number(s) in the StackTrace of an exception thrown in .NET to show up -
msdn says stacktrace
property of exception
class:
the stacktrace property holds stack trace, can use determine in code error occurred. stacktrace lists called methods preceded exception , line numbers in source calls made.
so know information available. how line numbers show in stack trace? code throwing exception in difficult , complex piece of code goes through tons of objects, don't want step through bazillion times see exception happening. stack trace of exception shows method signatures , no line numbers.
to line numbers in stacktrace, need have correct debug information (pdb files) alongside dlls/exes. generate the debug information, set option in project properties -> build -> advanced -> debug info
:
setting full
should suffice (see advanced build settings dialog box docs other options do). debug info (ie. pdb files) generated debug build configurations default, can generated release build configurations.
generating pdbs release builds enables ship code without pdbs, drop pdbs next dlls if need line numbers (or attach remote debugger). 1 thing note in release build, line numbers may not entirely correct due optimisations made compiler or jit compiler (this if line numbers show 0).
Comments
Post a Comment