locked
Visual Studio 2019 - Breakpoint will not hit and showing source code different from entirely different project - .Net Core RRS feed

  • Question

  • User-706403866 posted

    I am working on a Microservice based solution where in my same VS 2019 solution I have multiple microservice APIs, one API Gateway and two ASP.NET MVC presentation layer project. Everything was fine, till one day one of the presentation layer project's Startup.cs debug breakpoint will not hit.

    On hovering it shows, "The breakpoint will currently not hit. A copy of Startup.cs was found in <AnotherASP.NETMVCProject.dll>, but the current source code is different from the version built into <AnotherASP.NETMVCProject.dll>".

    Now the another MVC presentation project that I have, debugging works fine in its startup. Its weird why one MVC project debugging will not work stating source code is different in another MVC project. Also no source code modifications are done.

    Tried the following. Got no luck:
    1. Clean entire solution, rebuild
    2. Delete breakpoints, clean and rebuild and then add breakpoints and run
    3. Restarted machine, clean, rebuild
    4. Deleted manually all Bin folder contents and clean again and rebuild
    5. Closed VS, deleted ASP.NET temporary files and then restarted VS, clean and build

    I am at wit's end as to why this would happen all of a sudden. This seems like a VS 2019 bug. But any solution or workaround will help.

    Wednesday, October 7, 2020 4:16 AM

All replies

  • User1120430333 posted

    The breakpoint will not be hit until the source code the Visual Stuido project is using and the assembly/binary for the project deployed  to  the Web server are in sync. It's a clear indication that the source code for the project VS is using and the assembly/binary for the project on the Web server  are out of sync if the breakpoint icon on a code line in Visual Stuido that has been set is not a solid breakpoint icon.

    Wednesday, October 7, 2020 5:23 AM
  • User-706403866 posted

    But how is it out of sync without making any changes? It started to popup suddenly. Also the debugger is not getting hit on MVC Project A and hovering over it shows source code out of sync in MVC Project B. Why would Project A debugger not hit (even if Project B source code is out of sync. And Project B debugger works just fine)

    Also all the code is in my local running in IISExpress. So what is the workaround to this apart from the steps that I tried?

    Wednesday, October 7, 2020 7:22 AM
  • User1120430333 posted

    You could stop using IISExpress and push the solution out to local IIS on your machine and see if the problem follows.

    https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-enable-debugging-for-aspnet-applications?view=vs-2017

    Wednesday, October 7, 2020 4:58 PM
  • User475983607 posted

    debayan002

    But how is it out of sync without making any changes? It started to popup suddenly. Also the debugger is not getting hit on MVC Project A and hovering over it shows source code out of sync in MVC Project B.

    This symptom typically indicates a project pdb (debug) file is out of sync with the dll. The pdb file contains debugging symbols the debugger uses to create the debugger UI, single step, etc.  pdb files are created in debug configuration not release.   You should be ale to fix this issue by building all projects in debug mode.  Make sure the project you're debuging has the correct pdb files. 

    Also make sure the solution is in debug mode not release when starting the debugger.

    Wednesday, October 7, 2020 5:57 PM