Visual Studio breakpoints not being hit

后端 未结 19 2100
再見小時候
再見小時候 2020-12-04 18:59

I\'m working with an ASP.NET MVC project that seems to be having some issues when attaching to the IIS process (w3wp.exe). I\'m running the solution and IIS 8.5 on my own lo

相关标签:
19条回答
  • 2020-12-04 19:30

    Solved. Ended up being an incorrect configuration selected in the debug menu. I had mistakenly switched it to a release configuration that could not load the symbols for the document. Switched it to a debug configuration and the breakpoints hit just fine now.

    To add on to what Abacus mentioned below, it could also be a web.config transform that is messing with your build. In our case, we have Release configurations that remove the debug attribute from the web.config's compilation section. Below is a screenshot of an example and Visual Studio's dropdown list of build configurations.

    NOTE: Also make sure your Platform is correct along with the configuration. In my case, Dev.Debug|Mixed Platforms does not correctly build the solution but Dev.Debug|Any CPU will.

    0 讨论(0)
  • 2020-12-04 19:31

    Enable 'Managed Compatibility Mode'. Go to Tools->Options->Debugging and enable Managed Compatibility Mode.

    0 讨论(0)
  • 2020-12-04 19:32

    I know this is not the OPs issue, but I had this happen on a project. The solution had multiple MVC projects and the wrong project was set as startup.

    I had also set the configuration of the project(s) to just start process/debugger and not open a new browser window.

    Visual Studio Project Properties

    So on the surface it looks as if the debugger is starting up, but it does so for the wrong process. So check that and keep in mind that you can attach to multiple processes also.

    Silly mistake that left me scratching my head for about 30 minutes.

    Attach to both processes

    0 讨论(0)
  • 2020-12-04 19:36

    I struggled forever trying to fix this. Finally this is what did it for me.

    Select Debug->Options->Debugging->General

    Tick Enable .NET Framework source stepping.

    (This may be all you need to do but if you are like me, you also have to do the ones stated below. The below solution will also fix errors where your project is loading old assemblies/.pdb files despite rebuilding and cleaning.)

    Select Tools -> Options -> Projects and Solutions -> Build and Run,

    Untick the checkbox of "Only Build startup projects and dependencies on Run",

    Select Always Build from the "On Run, when project are out of date" dropdown.

    0 讨论(0)
  • 2020-12-04 19:36

    In my case this solution is useful:

    Solution: Disable the "Just My Code" option in the Debugging/General settings.

    Reference: c-sharpcorner

    0 讨论(0)
  • 2020-12-04 19:36

    If anyone is using Visual Studio 2017 and IIS and is trying to debug a web site project, the following worked for me:

    1. Attach the web site project to IIS.
    2. Add it to the solution with File -> Add -> Existing Web Site... and select the project from the inetpub/wwwroot directory.
    3. Right-click on the web site project in the solution explorer and select Property Pages -> Start Options
    4. Click on Specific Page and select the startup page (For service use Service.svc, for web site use Default.aspx or the custom name for the page you selected).
    5. Click on Use custom server and write

    http(s)://localhost/(web site name as appears in IIS)

    for example: http://localhost/MyWebSite

    That's it! Don't forget to make sure the web site is running on the IIS and that the web site you wish to debug is selected as the startup project (Right-click -> Set as StartUp Project).

    Original post: How to Debug Your ASP.NET Projects Running Under IIS

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