How the CLR locates pdb symbol files

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 12:06:14

问题


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?


回答1:


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");
    }
}



回答2:


Look at this blog post if you havn't already:

http://blogs.msdn.com/b/rmbyers/archive/2007/06/21/customizing-pdb-lookup-for-source-information-in-stacktrace.aspx



来源:https://stackoverflow.com/questions/8835018/how-the-clr-locates-pdb-symbol-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!