How to get the line number from a Stack Trace?

谁说胖子不能爱 提交于 2020-01-04 06:31:13

问题


I am trying to get the line number from a stack trace in my WP7 app. I have set debug info to full and am running the app in the Debug configuration, but there are no line numbers in stack traces. How can I fix this? I am aware of BugSense, but do not want to use it.


回答1:


Don't think this is even possible, as line number refers to the number of the line inside code-file, which has lost any relation with the binary after compilation. That's why we use PDB files. They are "databases" for holding the relation between actually executed code and the final binary state of it.

So don't think there would be any possibility to get a line number at runtime.

But if you have a PDB file of last compilation, you can potentially get that information from

StackFrame.GetFileLineNumber , which does:

Gets the line number in the file that contains the code that is executing. This information is typically extracted from the debugging symbols for the executable.



来源:https://stackoverflow.com/questions/12808075/how-to-get-the-line-number-from-a-stack-trace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!