msbg
msbg

Reputation: 4962

How to get the line number from a Stack Trace?

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.

Upvotes: 2

Views: 1758

Answers (1)

Tigran
Tigran

Reputation: 62256

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.

Upvotes: 1

Related Questions