I'm using VS2010 to develop my project. In my codebase, I use the stackframe's GetFileLineNumber()
function. At runtime, however, it always returns 0
. This happens even though I am running a debug build. I have also confirmed that the generated pdb file exists alongside the generated executable.
Any ideas?
Aha! I found the information squirreled away at the bottom of MS' reference post:
http://msdn.microsoft.com/en-us/library/system.diagnostics.stackframe.getfilelinenumber(v=vs.80).aspx
Turns out you have to construct your StackTrace instance like so:
st = new StackTrace(true);
The true
gets you file & line info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With