C# – Debugging with Pdb file and Source Code File in Visual Studio

cpdb-filesvisual studiovisual studio 2010visual studio 2012

I have a web project that posts from client-side code to a method in external dll, which I have source code file and pdb file of this external dll. What I would like to do is to debug external dll using source code file and pdb. Visual studio does not stop to say no symbols are loaded for the module since.

Best Answer

To debug a a symbol file with the same version is always needed. When you are debugging your own applications you usually don't have to care about this.

But there are things happening in the background. Visual Studio always puts the symbol files in the debug folder when you build your application and also loads them as described under Loading the symbols automatic.

(When you distribute your application you usually do not want to distribute those symbols and therefore they won't be copied to the release directory you change your build configuration to release.)

Loading the symbols manually

If you want to load the symbols manually you can load them with the Modules dialog.

"Debug" -> "Windows" -> "Modules".

You can right click a row and there is the option "Load Symbols" which lets you specify a PDB file to load.

enter image description here

Loading the symbols automatically

Visual studio also loads the symbols automatically when they can be found in one of the the places listed in the Specify Symbol (.pdb) and Source Files in the Visual Studio Debugger documentation:

  • The location that is specified inside the DLL or the executable file.

    (By default, if you have built a DLL or an executable file on your computer, the linker places the full path and file name of the associated .pdb file inside the DLL or the executable file. The debugger first checks to see if the symbol file exists in the location that is specified inside the DLL or the executable file. This is helpful, because you always have symbols available for code that you have compiled on your computer.)

  • .pdb files that could be present in the same folder as the DLL or executable file.

  • Any local symbol cache folders.

  • Any network, internet, or local symbol servers and locations that are specified on, such as the Microsoft symbol server if enabled.

enter image description here

If you want to read more about how the symbols are used with visual studio you can read this article about Understanding symbol files and Visual Studio’s symbol settings.