0

I recompile my solution, and when it starts in debug mode I get this warnings around my breakpoint saying that it won't be hit.

There is a copy of the source code file that is different.

Why would there be multiple versions of my source code loaded when trying to debug?

I even do a clean compile and still get this error.

1
  • I mainly get this for two reasons: 1. The project your trying to compile has been checked to not be compiled (see Solution's configuration) and 2. Your solution or project you're running is in Release Mode and not Debug. Have you checked this?
    – fared
    Commented Dec 16, 2020 at 21:51

2 Answers 2

1

Visual Studio is usually pretty good at detecting when your source code doesn't match the code signature of your attached exe or dll process. So I suspect that it is one of two possible issues:

  1. Your debug session's Platform/Configuration (e.g. Debug/x64) doesn't match the .exe or .dll compiled architecture. OR
  2. What you think is a "clean compile" isn't really clean.

The only source code that Visual Studio knows about is the one in front of you. But when Visual Studio is debugging an .exe or .dll, it is attaching itself to the .exe or .dll process, using reflection, and analyzing the code of that .exe/.dll. It determined that your .exe/.dll doesn't match the Platform/Configuration you wish to debug, or its reflected source code doesn't match the written code that is in front of you in Visual Studio's IDE.

When you say that you do a clean compile, make sure that it is really really clean (don't rely on the Visual Studio "Clean" feature. It's not reliable in all cases. For example, if you have created Build Events that copy contents pre- or post-compile. Instead, delete your project's /bin and /obj folders, then recompile. That will ensure your binaries always match your latest code for debugging. Do this a few times, and see if you still get the issue.

1
  • I also clicked on the IIS express in my toolbar and shut it down...no change. I just rebooted and now it works? Good tips on deleting the /bin folder etc.
    – Blankman
    Commented Dec 16, 2020 at 22:18
0

I had same error in VS 2019 .I solved that way;

Tools->Options->Debbuging->General and "Require source files to exactly match the orginal version" deselect that option

Not the answer you're looking for? Browse other questions tagged or ask your own question.