2

When I create a StackTrace object with parameter bool fNeedFileInfo = true, I get the file names and line numbers from my own code. But for a deeper analysis of a Winforms project I also need the file names and line numbers of the .net code.
I already configured VS 2015 to allow stepping into .net source code and I can see the needed info in the Stack Frame dropdown field of Visual Studio, but I cannot get this info programmatically in my code for debug output.

Is there a way to programmatically query the .net code file names and line numbers of a stack frame?

Tobias Knauss
  • 3,361
  • 1
  • 21
  • 45
  • That is not practical. On your dev machine VS knows how to obtain the required PDB files from the right symbol server. Which [often fails](https://stackoverflow.com/a/27655501/17034). You have no control over the user's framework version. – Hans Passant Jun 03 '19 at 10:03
  • @HansPassant: I'm definitely not creating this code for use on a customer's computer. It's solely for my own analysis of how my code works. – Tobias Knauss Jun 03 '19 at 10:05
  • Then just copy the PDB files you need from the symbol cache. You can use the trace or the Symbol Load Information context menu command in the Debug > Windows > Modules pane to see where they are stored. – Hans Passant Jun 03 '19 at 10:07
  • @HansPassant: Copy them to which place? Debug output folder of my exe? As I wrote, I can already step into the code and VS tells me the line numbers, just my program does not. // Next problem would be: e.g. System.pdb, which one should I take? The symbol cache contains multiple versions of it. – Tobias Knauss Jun 03 '19 at 10:09
  • @HansPassant: I've copied `System.pdb` and `System.Windows.Forms.pdb` to both `.\bin\x86\Debug\ ` and `.\obj\x86\Debug\ `, AND I can see in the "Modules" window that they're used (from bin folder)! But I still dont' get file numbers in the debug output, although I can see them in the "Call Stack" window and the "Stack Frame" dropdown. – Tobias Knauss Jun 03 '19 at 10:21

0 Answers0