Categories
.net breakpoints c# debugging visual-studio

How do I remedy “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning?

1933

A C# desktop application (on the Visual Studio Express/Community edition) worked, but then it didn’t work 5 seconds later.

I tried the following:

  • Ensure debug configuration, debug flag, and full debug information are set on all assemblies.
  • Delete all bin and obj folders and all DLL files related to the project from my entire machine.
  • Recreate projects causing the problem from scratch.
  • Reboot.

I have two Windows Forms projects in the solution. One of them loads the debug information, one doesn’t. They both refer to the assembly I’m trying to get debug information on in exactly the same way in the project file. Any ideas?


I want to add here, mostly for myself when I come back to review this question, that symbols are not loaded until the assembly is loaded, and the assembly is not loaded until it is needed. If the breakpoint is in a library that is only used in one function in your main assembly, the symbols will not be loaded (and it will show the breakpoint as not being hit) until that function is called.

20

  • 150

    When debugging, goto to the Debug, Windows, Modules view. This will show info about loaded modules and symbol status. You can right click a module and try to load the symbols from another location.

    – Polyfun

    Jan 28, 2010 at 16:19

  • 17

    Express edition does not have Modules view.

    Jan 28, 2010 at 16:25

  • 15

    Good point about assemblies not loaded until needed. The debugger will show that the breakpoint won’t be hit, but the display will change/your breakpoint WILL be hit once the assembly is loaded. A cheesy workaround this UI issue would be to make a call to the assembly at program start to force the assembly to be loaded.

    – Tim Coker

    Oct 17, 2011 at 13:16

  • 2

    I had same issue and I noticed that for this build configuration I didn’t have <DebugSymbols>true</DebugSymbols> under it in VS2015 I manually added it and it worked fine.

    – kuskmen

    Nov 21, 2016 at 8:07

  • 7

    Removing the .suo file might have solved this ugly problem at my project

    – Roland

    Jun 1, 2017 at 21:02

1259

Start debugging, as soon as you’ve arrived at a breakpoint or used Debug > Break All, use Debug > Windows > Modules. You’ll see a list of all the assemblies that are loaded into the process. Locate the one you want to get debug info for. Right-click it and select Symbol Load Information. You’ll get a dialog that lists all the directories where it looked for the .pdb file for the assembly. Verify that list against the actual .pdb location. Make sure it doesn’t find an old one.

In normal projects, the assembly and its .pdb file should always have been copied by the IDE into the same folder as your .exe, i.e. the bin\Debug folder of your project. Make sure you remove one from the GAC if you’ve been playing with it.

2

  • 39

    The question is about express edition, to which this answer does not apply, unfortunately. Actually none of the answers work for me, I also tried removing the Debug folder and rebuilding.

    Sep 21, 2012 at 8:56

  • 1

    Info that saves lives! Thank you!

    – Gxzzin

    Oct 19, 2021 at 19:10


660

Check if you are not in release but in Debug.

When in debug:

First try rebuilding your project by right mouse click the project > Rebuild
If that doesn’t work, try a clean of the project (right mouse click on the project > clean)

If that didn’t work check this:

  1. Right mouse click your project
  2. Select [Properties]
  3. Select the [Build] tab
  4. Make sure [Define DEBUG constant] and [Define TRACE constant] are checked
  5. Make sure [Optimize Code] is unchecked
  6. Click the [Advanced] button at the bottom of the Build tabpage
  7. Make sure that [Debug Info:] is set to [full]
  8. Click [OK] and rebuild the project 😉

(step 7 generates the .pdb files, these are the debugging symbols)

5

  • 45

    Make sure that [Debug Info:] is set to [full] – fixed it for me! I have multiple configurations set up on my project, the new ones I added didn’t have this set.

    – Chiefy

    Feb 13, 2014 at 9:35

  • 59

    Turns out I was in the release build. tsk.

    – Aloha

    Aug 29, 2015 at 12:49

  • In C++, we can enable “generate minimal debug info for release“, where the .pdb file acts like so-called “source-maps” (known from JavaScript), but without losing any optimization or performance.

    Apr 20 at 15:46

  • Does C# support something like that for release?

    Apr 20 at 15:46

  • Your instructions are easy to understand. it perfectly worked for me.

    Jun 11 at 5:53


304

Just something simple to try – you may have tried it already.
Right click the Solution in solution explorer, click “clean solution”, this deletes all the compiled and temporary files associated with a solution.

Do a rebuild of the solution and try to debug again.

I’ve also had troubles with breakpoints multiple projects in a solution – some compiled as x86, some as x64.

0