'VS 2022 debugging: Sometimes works, sometimes get "breakpoint cannot currently be hit, no symbols loaded..."

I have a .Net web project that I publish and then attach VS to w3wp.exe for debugging. I place breakpoints, load the specific web page being modified, and debug... over and over. This works fine for a while but then it just quits hitting the breakpoints and gives the error: "breakpoint cannot currently be hit, no symbols loaded.." with a hollow circle for the breakpoint. I cannot say what causes it to stop hitting the breakpoints. I'm just coding, publishing, debugging, repeating.... then I'm not. So, I do the following:

delete all debug and release folders, delete the obj and bin folders rebuild the solution restart VS 2022 restart computer update NuGet make sure still configured for debug build

I did have some luck deleting all the files/folders in C:\Users\stever\AppData\Local\Temp\2 with today's date. In fact, I thought it WAS the fix because it fixed the issue a number of times and I was able to debug again. However, that stopped working too.

I did all the things mentioned a number of times and finally did get it to hit the breakpoints again. This has happened a lot! It sure would be nice to know what's causing this and what I need to do in order to debug again every time it happens. Any ideas for a fool-proof fix?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source