GetFileLineNumber () returns 0, although I use a debug build

I am using VS2010 to develop my project. In my code base, I use the stackframe GetFileLineNumber() function. However, at runtime, it always returns 0 . This happens even though I run a debug build. I also confirmed that the generated pdb file exists along with the generated executable.

Any ideas?

+4
source share
1 answer

Yeah! I found the information running at the bottom of the MS help mail:

http://msdn.microsoft.com/en-us/library/system.diagnostics.stackframe.getfilelinenumber(v=vs.80).aspx

Turns out you should build your StackTrace instance like this:

 st = new StackTrace(true); 

true gets file and line information.

+11
source

Source: https://habr.com/ru/post/1398682/


All Articles