首页 文章

为什么visual studio无法加载之前存储的符号?

提问于
浏览
0

我有以下奇怪的情况(至少对我来说)情况 .

  • 我在 D:\Test 文件夹中创建了简单的控制台应用程序 . 代码如下
static void Main(string[] args)
{
    Console.WriteLine("Dumps hello world !");
    int i = 5 + 5;
    Console.ReadLine();
}
  • 构建解决方案并将exe文件复制到另一个文件夹 D:\Test2 . 从该文件夹运行应用程序,创建转储文件(使用任务管理器),使用visual studio打开此转储,单击"Debug with Mixed" . Visual Studio能够加载符号,我可以从visual studio分析转储文件 . 一切都好

现在我想要以下内容
a) modify current source code in folder D:\Test b) be able to analyze dump files for old exe file in folder D:\Test2.
所以,为了实现这一点,我为旧的.pdb文件做了备份 . 我把它复制到 D:\StoredSymbols 文件夹中

  • 将源代码更改为以下内容
static void Main(string[] args)
{
    Console.WriteLine("Dumps hello world !");
    Console.WriteLine("Some minor changes");
    int i = 5 + 5;
    Console.ReadLine();
}
  • D:\Test2 运行旧的exec文件,进行进程转储,使用visual studio打开它,单击"Debug with Mixed" . 正如预期的那样,Visual Studio尝试从 D:\test 文件夹加载符号而不能这样做.pdb文件已经对应于新的exe文件,而不是旧文件 .

  • 所以我为.pdb文件设置了新路径 - D:\StoredSymbols 但是visual studio仍然无法分析转储文件!

为什么?
我该怎么做才能完成 tasks ?这是截图

enter image description here

这是我的Debug - > Modules截图

enter image description here

1 回答

  • 0

    在附带的屏幕截图中,它说它跳过加载 mscorlib.dll 的符号,并且它说的是原因('Just My Code') .

    我不认为你是在问这些符号 . 你想加载你的 . 如果您检查 Debug->ModulesSymbol Load Information (在上下文菜单下),那么您可能会看到"PDB does not match image"的信息 . 据我所知,VS要求符号来自与图像相同的构建,因此除非你伪造符号,否则无法克服这个问题 . 这可以使用R#(付费)或dotPeek(免费)来完成 . dotPeek带有一个符号服务器,可按需提供PDB .

    基本上,您将dotPeek符号服务器作为符号服务器添加到VS,它将根据需要生成PDB .

    我已经记录了如何做到这一点:Debugging without source code with dotPeek Symbol Server

相关问题