Visual Studio: The breakpoint will not currently be hit. The source code is different from the original version.

Some strange things happened today while I was testing some new code. The first problem was that the new code that I wrote wasn’t compiling when I attempted to debug. There were no compiler errors and the build was successful but upon debugging, the changes to the code that I made were not being executed. So, I tried to put a breakpoint at the location of the new code only to be confronted with the below error:

I have seen this error when you have compiler errors but decide to continue debugging using the last successfully compiled version, but this wasn’t the issue as everything was compiling correctly.

I figured something got corrupted in my project configuration so I built the project by right clicking on the project name in the Solution Explorer and clicking Rebuild. This will delete all temporary and intermediate files that are created while compiling and then compile the application from the ground up.

This solved my problem for a while but I was soon confronted with the same situation. I was baffled as I had never seen this problem occur and I didn’t want to have to rebuild the project every time I debugged as that took quite a bit longer. It was then that I realized that what I was doing during my testing was effecting the compilation process.

I was working on a clock in/out system that hooked into the SystemEvents.TimeChanged event so that I could detect changes in the system clock. During my debugging I would change the date and time on my computer to future and past dates, stop debugging, make some more changes, and then run my application again. From what I could gather, Visual Studio was getting confused as the modified date on the source code files were all out of wack. I would save my changes with the correct date and time, then change the system clock during testing, make more changes and save again but this time it saved as a date in the past. Thus, when compiling, Visual Studio would think the previous build was actually more current and not take into account the changes I made. This explains why the Rebuild command worked as it got rid of any files that had been created in previous builds and Visual Studio had no date reference to use when deciding which files to compile.

If you are messing with the date and time during debugging, be aware of this issue.


One Response to “Visual Studio: The breakpoint will not currently be hit. The source code is different from the original version.”

  1. Anish Says:

    Thanks, It helped me a lot.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: