Search code examples
c#.netvisual-studiodebuggingbreakpoints

"Source Not Found: You need to find class to view the source for the current call stack frame" as result when debugging project code


While investigating issues in a .net solution, I am encountering problems as I am unable to do debug or do any action. This is causing issues with debugging, such as breakpoints hitting or setting them properly. The issue is where Visual Studio isn't able to find any source classes of the solution and its projects. It loads them as external sources, and allows showing some classes during debugging but not the actual source code breakpoints or parameter values during the run.

The issue is shown as: Source Not Found: Issue encountered

This happens for example when it hits one of previously defined breakpoints on any possible class in any project in the solution. Where these get loaded under:

External Sources under the Solution Explorer

Amongst the tried options were (which all were unsuccessful, and why I am here searching for answers):

  • Testing on another machine.
    • Not occurring on the other machine/machines.
  • Removing the .vs folder within the solution.
  • Re-clonning the project.
  • Updating Visual Studio.
  • Setting MSBuild project build output verbosity: Diagnostic output under Tools => Options => Project and Solutions => Build and Run.
  • Disabling Enable address-level debugging under Tools => Options => Debugging.
  • Enabling Just My Code** under Tools => Options => Debugging.

Ideally would be to have proper debugging capabilities and run without having this issue where it occurs that my project depends on external sources to run and being unable to properly debug.


Solution

  • I was not able to pinpoint the actual issue on what caused it. As it was most probably based on the actual issue, related to local development environment setup, and as @Minxin YU -MSFT mentioned, resetting it would probably resolve it. Which it did. But it did not provide any information on what was the actual root cause.

    There are multiple options of doing it, and here are some I tried:

    1. Using the Repair functionality from the Visual Studio Installer Repair - Visual Studio Installer

      • Which will reset the whole environment.
    2. Using the Tools ⇾ Import and Export Settings feature and resetting it from there. enter image description here

    3. And using the Developer Command Prompt option

      devenv /ResetSettings

    The one that worked for me was, the first option.