Home > Net >  Why does VS 2022 always stop on the first code line while debugging
Why does VS 2022 always stop on the first code line while debugging

Time:01-03

I recently updated my VS Enterprise 2022 installation to version 17.4.2. Since than, when debugging into a method (pressing F11), the debugger does not step into the method, but instead stops at the first line of the code file containing the method.

I tried to use a launchsettings.json file like this:

{
  "profiles": {
    "MyProject": {
      "stopOnEntry": false
    }
  }
}

but this does not work e.g. for unit tests. Also, the solution includes more than 180 projects, which makes it a little bit boring to modify each of them.

So my question: Is there a settings switch to generally disables this behavior? I did not find anything in the options...

CodePudding user response:

I've seen this bug too, not only while debugging, but also when clicking on a result in the find-in-files window or sometimes in the call stack. I suspect the problem happens because it tries to move to a specific line before the file is actually open. The bug does (typically) not happen if the file one wants to step into is already open. A workaround is to double click again on the top of the call stack. That will move the cursor to the correct position.

I'm not sure, but I think I have not seen the bug in the latest preview version (17.5.0 Preview 2).

  • Related