If I get a stack trace by using new StackFrame() or new StackTrace(), I can pass in ‘true’ to fNeedFileInfo to get file and location info. This requires a PDB file to work.
My question is: how does the CLR look for the PDB file?
Our end users don’t have PDB’s locally, but they are available on a network share. Is it possible to tell the CLR where they are when it does the stack trace?
The CLR uses the DIA (Debug Interface Access) API to resolve source and line information. DIA respects the
_NT_SYMBOL_PATHenvironment variable when resolving symbols. You can specify multiple folders (local or network) or symbol servers. See here for the specific syntax.Given this, you can use
Environment.SetEnvironmentVariableto set the symbol path for your process. For example……specifies that you want to look for symbols in both your local network share as well as the public Microsoft symbol server. Note that looking for symbols over the network can really slow things down. This is probably not an issue if you’re using
StackTrace, though.