Visual Studio breakpoints break in the wrong place

This is obscure, so I'm posting it here to save someone the few hours I just spent. I recently clicked "Tools/Options/Debugging/Require source files to exactly match the original version." A little later, without realizing it was related to this config change, I discovered my debugging cursor was moving through code in a strange manner.

The highlight bar was wrong, it was stopping on lines with no code, and it even looped where there was no loop. It took me several hours to discover the cause: I was attaching to a running process, believing that the running process was actually using the same code I had just built. In fact, it was using a prior build. The debugger will happily step through the lines of the prior build in this case.

Here are some other causes of the same problem:

http://stackoverflow.com/questions/12416192/visual-studio-breakpoints-break-in-the-wrong-source-file-or-multiple-files-simu

https://social.msdn.microsoft.com/Forums/vstudio/en-US/d634b25f-0b28-41b1-a393-8b4a7782e32f/debugger-highlights-wrong-line-steps-over-code-without-executing-it

http://joelblogs.co.uk/2010/02/10/visual-studio-2008-%E2%80%93-when-debugging-highlights-the-wrong-line/

Add a comment

HTML code is displayed as text and web addresses are automatically converted.

Page top