Breakpoint Not Being Hit: "Source Code Is Different"...but it's not

Mark Olbert 6 Reputation points
2021-06-27T00:00:08.807+00:00

I am debugging a C# (NET5) WPF app built under the latest non-preview VS 2019. Sometimes I need to attach a separate instance of VS' debugger to the process WpfSurface.com in order to debug design-time problems.

This works reasonably reliably on my desktop system, in that I can set breakpoints as usual, step through code, etc., in the second instance of VS.

But on my Surface Pro 6 (also running the latest non-preview VS 2019) it's wonky. Occasionally that second instance warns me I can't hit a breakpoint because "the source code may be different". It then offers advice on how I can let the breakpoint be hit by changing settings (that help doesn't work, BTW -- they're still not hit).

What confuses me is the file I want to set a breakpoint in is >>exactly<< the same file as I'm editing in the other/primary VS 2019 instance. I've compiled the project so I know there are no unsaved changes.

So why is the second instance of VS2019 warning me about potential differences? Is it looking at a cached version? If so, how do I tell the second instance to clear the cache and reload the actual file? I've tried closing that second instance of VS and re-opening it but that doesn't seem to fix the problem.

Again, this is something I run into frequently on my Surface Pro 6 but rarely, if ever, on my desktop...which is really, really puzzling since they both run the same versions of Windows and VS 2019.

Developer technologies Windows Presentation Foundation
Developer technologies Visual Studio Debugging
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,436 Reputation points Microsoft External Staff
    2021-06-28T06:52:56.48+00:00

    Hello @Mark Olbert ,

    Welcome to Microsoft Q&A forum.

    Perhaps you can try this method: Close every VS instances and go to project/solution folder and delete the .vs, bin and obj folder. Then open VS and open your project Clean > Rebuild it, then debug again.

    Feel free to let me know if it works.

    Best Regards,
    Tianyu

    • If the answer is helpful, please click "Accept Answer" and upvote it.
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

  2. Duane Arnold 3,216 Reputation points
    2021-07-08T07:45:33.55+00:00

    Did you try a Clean and Build?

    0 comments No comments

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.