Visual Studio 2019 sometimes won't compile/link in new changes, resulting in inactive breakpoints?

Carl Colijn 96 Reputation points
2020-11-11T15:36:35.817+00:00

I'm using Visual Studio 2019 Professional (version 16.7.7+30621.155), and when I'm compiling a big C++ DLL project (incl. our own static libs) the compiler and/or linker sometimes refuses to take in minor updates to the code.

Scenario:

  • I stop a debug session and alter a line here and there in the static lib part of the code,
  • I press F7 to recompile, and I see the static lib gets recompiled and the final DLL gets relinked,
  • I press F5 to run the host app which loads my DLL in turn,
  • The existing breakpoints in the file I just changed are now non-functional, saying that "The source code is different from the original version".

It doesn't happen every time, but enough times to really start to annoy me. A remedy is to clean and/or rebuild all, but in my case that is a lengthy process which I'd rather not do too often. I already once checked the timestamps of both the altered source file and the corresponding cached object file, and the object file did get updated...? Just now I also encountered this issue again, and I decided to "Project only \ Rebuild", and while it did rebuild the static lib the breakpoint is still inactive with the same message...? The object file's timestamp is a few minutes newer than the cpp file's timestamp, so I assume my changes got compiled in?

I also sometimes used to have this issue now and then under VS 2017 (using the 2015 toolchain), but one day the problem went away and I never saw it again. Until I now upgraded to VS 2019.

What could be the problem here?

ps: after writing this post I added+removed a space to the cpp file in question, pressed F5, the file got recompiled and the project re-linked, and now the (unaltered) breakpoints work again. It almost seems as if the compiler and/or linker use a minutes-only time resolution when comparing file time stamps, but that can't be true, right?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,032 questions
{count} votes

Accepted answer
  1. Carl Colijn 96 Reputation points
    2020-11-11T17:39:07.5+00:00

    There apparently is a VS option named "Only build startup projects and dependencies on Run", and if your workflow consists of just pressing F5 to win, having this option accidentally unchecked will make your life miserable. Or rather frustrating and confusing that is, when you do sometimes sprinkle in an F7 so that "sometimes it works, sometimes it doesn't".

    Thanks @David Lowndes for your other suggestions and putting up with me anyway :)

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.