How to use Stacktrace to return Error Line Number in vb.net

后端 未结 7 1085
名媛妹妹
名媛妹妹 2021-02-05 20:08

I am trying to create some sort of error catching method that will return the error line number. We have an abort email that is sent out when a process aborts that gives us the

相关标签:
7条回答
  • 2021-02-05 21:04

    Generating line numbers in exception stack traces is a built-in feature for the CLR. You do however have to provide the information it needs to map a code address to a line number. Switch to the Release configuration of your project. Project + Properties, Compile tab, Advanced Compile Options. Change the "Generate debug info" setting from pdb-only to Full. Deploy the .pdb files along with your program.

    Beware that the line number you get is always an estimate so do not blindly trust what you see. The mapping is imperfect due to the jitter optimizer inlining methods and otherwise moving code around to make the program run faster.

    0 讨论(0)
提交回复
热议问题