Monday, February 8, 2010

Breakpoint Will Not Currently Be Hit

Ever hit a hurdle debugging a .Net Application? Especially "Breakpoint will not currently be hit. No symbols have been loaded for this document." This is the most deadliest of all. I say this not because it is tough to overcome it, but because it really destroys your productivity. I usually call such hurdles "Productivity Roadblocks"

What CAUSES the Breakpoint will not currently be hit?

This happens primarily because either the .pdb file is not present, there is a mismatch between the .pdb file and the source, or the .dll file that you wish to be debugged has not been loaded.

Is there a RESOLUTION?
Of course there is there are. You may want to try these in sequence as mentioned:

  1. Set the configuration option to Debug in the Configuration Manager
  2. Delete the .pdb files in your bin folders > Recompile the project > Run
  3. Delete and reload all referenced .dlls
  4. Delete all .pdbs and .dlls from the bin and obj folder. Reload the .dlls > Recompile > Run
  5. Close Visual Studio IDE and restart. Rebuild and Run. Surprisingly it works
  6. Restart your computer. Rebuild and Run. I refer to this as the "Windows Magic"
  7. Make sure that the XML Element "compilation" tag in your web.config file has an attribute with debug = "true". Only if this is enabled, web apps and services have their .pdb files generated with the .dlls

Another Tip

  • While debugging in Visual Studio, click on Debug > Windows > Modules. The IDE will dock a Modules window, showing all the modules that have been loaded for your project.
  • Look for your project's DLL, and check the Symbol Status for it.
  • If it says Symbols Loaded, then you're golden. If it says something like Cannot find or open the PDB file, right-click on your module, select Load Symbols, and browse to the path of your PDB.

I've reached as far as this. There might be other ways to overcome this. If there are, drop in a comment below. I don't want developers to suffer their debugging process. That's the only way they can spy on every single variable and other declarations.

Happy coding!!