How to tell StackTrace where to find your PDB?

If I get a stack trace with new StackFrame()or new StackTrace(), I can pass "true" on fNeedFileInfoto get the file and location information. This requires a PDB file.

My question is: how is the CLR looking for a PDB file?

Our end users do not have PDB locally, but they are available on a network share. Is it possible to tell the CLR where they are when it performs a stack trace?

+3
source share
2 answers

The CLR uses the DIA ( "Debug Interface Access") API to resolve source and line information. DIA respects the environment variable _NT_SYMBOL_PATHwhen resolving characters. You can specify multiple folders (local or network) or symbol servers. See here for specific syntax.

Given this, you can use Environment.SetEnvironmentVariableto set the symbol path for your process. For instance...

Environment.SetEnvironmentVariable(
    "_NT_SYMBOL_PATH",
    @"\\local\symbol\share;srv*http://msdl.microsoft.com/download/symbols"
);

... indicates that you want to search for characters in both a network share and a Microsoft public symbol server. Please note that searching for characters over the network can really slow things down. This is probably not a problem if you use StackTrace.

+1
source

CLR COM- .pdb diasymreader.dll, framework. (ISymUnmanagedReader). MSDN - . CLR .

. DLL. HKLM\Software\Microsoft\VisualStudio\MSPDB SymbolSearchPath. , , Regedit.exe. , .pdb.

+1

All Articles