Web API in MVC Project isn't hitting breakpoints (“symbols not loaded”)

后端 未结 7 1464
死守一世寂寞
死守一世寂寞 2020-12-30 07:05

I have an ASP.NET MVC project, with an ASP.NET web api defined as an area in this project. So the structure is the following:

MVC Web
   Controllers
   View         


        
相关标签:
7条回答
  • 2020-12-30 07:30

    I had the same issue but mine was related to the addition of a config Transform. Go to Build > Configuration Manager under Active Solution Configuration make sure you have Debug selected.

    0 讨论(0)
  • 2020-12-30 07:34

    Possible solution: I had forgotten that I was previously doing some remote debugging and had set debug symbols to be loaded from a UNC path instead of the Microsoft Symbol Servers.

    To fix this head to: Tools -> Options -> Debugging -> Symbols -> Make sure 'Microsoft Symbol Servers' is checked.

    I also found this issue from creating a new Solution Configuration and not basing it on any existing configuration, such as the DEBUG configuration. That caused Debug Info to be set to none.

    To fix this: Right-click your project -> Properties -> Build -> Make sure your faulty Solution Configuration is set -> click Advanced -> change Debug Info to full.

    0 讨论(0)
  • 2020-12-30 07:36

    This solved my problem:

    • Close\Exit from all instances of IIS Express in the system tray (beside the Windows clock).
    • Delete bin and obj folders in your project directory
    • Restart Visual Studio
    • Run it again

    0 讨论(0)
  • 2020-12-30 07:41

    Until you find a permanent solution you can use the method System.Diagnostics.Debugger.Break() to force a break to occur on that line - just like a breakpoint:

    public ActionResult IndexCheckInOut(string providerKey, DateTime? date = null)
    {
        System.Diagnostics.Debugger.Break();   
        return View("Index");
    }
    

    Here are some links to articles that might help you find a more permanent solution:

    The breakpoint will not currently be hit

    Stepping into ASP.NET MVC source code with Visual Studio debugger

    0 讨论(0)
  • 2020-12-30 07:44

    Just had this issue myself and was tearing my hair out for about an hour until I realised Visual Studio had mysteriously switched to run the project in 'Release' mode. Switching back to 'Debug' mode and rebuilding sorted me out.

    Probably a very niche answer to this problem, but hopefully this helps somebody.

    0 讨论(0)
  • 2020-12-30 07:45

    For me it worked out to just stop IIS and restart Visual Studio. Definitely worth a try before further investigation.

    0 讨论(0)
提交回复
热议问题