1

So I'm trying to add some new code to a project I'm working on, but Visual studio is not cooperating at all.

The project is only hitting breakpoints on code that existed prior to this set of changes. See the screenshot below, where the top and bottom breakpoints are pre-existing code, and some new code is inside the if statement.

I have no idea where to start, I've tried a clean and rebuild, to no avail.

enter image description here

Scuba Steve
  • 1,541
  • 1
  • 19
  • 47

3 Answers3

2

Solved:

Debug Menu -> Options -> Debugging -> General -> Uncheck Suppress JIT optimization on module load

I'm not sure why it decided to start acting up now(haven't had this problem for a year of work on this project), but I'm guessing the code I'm trying to debug was optimized away.

Scuba Steve
  • 1,541
  • 1
  • 19
  • 47
  • If you had to uncheck the suppression of optimization in order for it to work then wouldn’t that mean the code NOW is being JIT optimized? – Jazimov Apr 13 '18 at 21:44
  • Yeah I guess it would. I had my thinking backwards. Well this problem makes even less sense now! I wonder what about suppressing JIT optimization causes breakpoints not to be hit... maybe it's a bug.. – Scuba Steve Apr 19 '18 at 00:44
0
  1. Do a Rebuild All. (I see you tried that--I listed for others to consider.)

  2. Make sure all dependencies for the code in question are current. You might have a project reference to an assembly (DLL) that has since fallen out of sync with its PDB/source code. Be sure all references point to currently compiled code.

  3. I've sometimes seen this happen and an exit/restart of Visual Studio (all instances, just to be safe) works.

If any of these ideas work, please let us know which one did.

Jazimov
  • 12,626
  • 9
  • 52
  • 59
  • 1. I've done a rebuild all, no luck 2. Dependencies haven't changed. I'm the sole developer. 3. I've tried this, it was like the first thing I did. Including a computer restart. – Scuba Steve Apr 13 '18 at 19:11
  • Based on what you wrote, find the .pdb file for the assembly in question (i.e., the one on which you cannot set the breakpoint) and manually delete it. I say that to ensure that nothing is holding a lock on the pdb, preventing it from getting updated on a rebuild. Also, as crazy as this sounds, UNSET then set the breakpoint again--maybe even twice. I have seen cases where the error appears but then disappears on a subsequent attempt to set the breakpoint, and I can't figure out when/why that happens. I use VS 2017 Enterprise latest version. – Jazimov Apr 13 '18 at 19:20
  • That's pretty wild. I even switched versions of VS and created a brand new build from the remote. The JIT thing did the trick, can't explain why though. – Scuba Steve Apr 26 '18 at 00:46
0

I went through the same issue, tried everything above and the solution for me was to do: Debug > Delete all breakpoints to start fresh.

Sylvain C.
  • 1,043
  • 1
  • 11
  • 27