Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Breakpoint Warning

Tags:

When debugging my code, I often throw breakpoints in to check the values of local variables to make sure everything is on the right track.

Lately, when I make changes to my code and recompile, all my breakpoints turn into the outline of a circle (instead of a full red circle) and it gives me an error that reads;

The breakpoint will not currently be hit. No executable code is associated with this line. Possible causes include: conditional compilation or complier optimizations.

What's strange about this issue is that I can simply remove and add the breakpoint and everything will work completely fine.

I am not using any type of conditional compilation or complier optimizations. Does anyone know what this means or how to fix this? It gets quite annoying replacing 10-12 breakpoints each time I compile.

like image 992
Kyle Uithoven Avatar asked May 23 '11 17:05

Kyle Uithoven


1 Answers

This can happen for a few reasons

  • The code the debugger is using is different from the code that the application is running
  • The pdb file that the debugger is using is different from the code that the application is running
  • The code the application is running has been optimized and debug information has been stripped out.
  • The code in which you have breakpoints on hasn't been loaded into the process yet (assuming the things above are not the culprits)
  • If you are attaching the debugger, pay attention to what .net framework it's attaching to (i've had issues with it using .net 4 when code was all .net 2.0)
  • The assembly you have is also in the GAC. This might happen if say you installed your program so you could debug it, but the installer put the dll in the GAC.
  • Remove the reference and re-add it (thanks to forsvarir). Typically this occurs when the project that is referenced is not in the solution, and VS will copy the dll from the bin directory of another project. You will know this was the issue when you try to re-add the reference, and can't find the project :)

It's pretty tough to figure out what's going on here, but i would suggest using the fusion log viewer to see what is being loaded and where it's being loaded from and then you can look at the dll and see if it's old code, etc.

like image 142
Darren Kopp Avatar answered Jan 25 '23 04:01

Darren Kopp