Debugging a release version of a DLL (with PDB file)

If I have a DLL (that was built in release-mode) and the corresponding PDB file, is it possible to debug (step-into) classes/methods contained in that DLL?

If so, what are the required steps/configuration (eg where to put the PDB file)?

Edit:

If have the PDB file in the same place as the DLL (in the bin/debug directory of a simple console test application). I can see that the symbols for the DLL are loaded (in the Output window and also in the Modules window), but still I cannot step into the methods of that DLL.

Could this be the result of compiler optimizations (as described by Michael in his answer)?


The pdb is usually (for me at least) detected if it is next to the dll (like with the intellisense xml files).

Alternatively; you'll need a break point after the module has loaded...

At the break-point, bring up the "Modules" window (Ctrl+D,M - or Debug->Windows->Modules). Right click on your dll "Load symbols from", "Symbol path", etc.


Yes, you can debug release code with a PDB. There are some pitfalls however with debugging optimized code, more info here and here.

Your PDB just needs to be in a place that the debugger can find it - for local debugging same directory as the dll is usually easiest. Otherwise, put it in some place that the debugger can find it, and point the debugger to that place with the symbol path.


I finally found what cause the problems debugging a DLL that was built in release configuration:

First of all, it basically works as expected. Which means, if I have a DLL built in release-configuration plus the corresponding PDB file, then I can debug the classes/methods contained in that DLL.

When I first tried this, I unfortunately tried to step into methods of a class which has the DebuggerStepThroughAttribute , eg:

[System.Diagnostics.DebuggerStepThrough]
public class MyClass {
    public void Test() { ... }
}

In that case, it is of course not possible to step into the method from the debugger (as expected/intended).

So everything works as intended. Thanks a lot for your answers.

链接地址: http://www.djcxy.com/p/74556.html

上一篇: 防止引用的程序集PDB和XML文件复制到输出

下一篇: 调试DLL的发布版本(使用PDB文件)