如何在CLR定位PDB符号文件 [英] How the CLR locates pdb symbol files
问题描述
我想知道如何在CLR查找PDB符号文件,如果这种行为可以被覆盖。
I would like to know how the CLR locates pdb symbol files, and if this behavior can be overridden.
我在网上看了(MSDN和其他资源),也没有找到一个很好的答案。
I looked online (MSDN and other resources) but could not find a good answer.
在我的应用程序,我有放置在主.EXE路径的几个子目录的DLL。
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?
推荐答案
您可以简单地设置_NT_SYMBOL_PATH环境变量为自己的过程。这种行之有效:
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");
}
}
这篇关于如何在CLR定位PDB符号文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!