I would like to know how the CLR locates pdb symbol files, and if this behavior can be overridden.
I looked online (MSDN and other resources) but could not find a good answer.
In my app, i have DLLs placed in several subdirectories of the main .EXE path.
I would like to have a Symbols\ dir that will contain all symbols for my application. By default, i believe that symbols are picked up from where the assembly is. Can this be changed?
You could simply set the _NT_SYMBOL_PATH environment variable for your own process. This worked well:
using System;
using System.Runtime.CompilerServices;
using System.Reflection;
using System.IO;
class Program {
static void Main(string[] args) {
var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
path = Path.Combine(path, "symbols");
Environment.SetEnvironmentVariable("_NT_SYMBOL_PATH", path);
try {
Kaboom();
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
Console.ReadLine();
}
[MethodImpl(MethodImplOptions.NoInlining)]
static void Kaboom() {
throw new Exception("test");
}
}
Look at this blog post if you havn't already:
来源:https://stackoverflow.com/questions/8835018/how-the-clr-locates-pdb-symbol-files