Visual Studio breakpoints not being hit

后端 未结 19 2102
再見小時候
再見小時候 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:36

    You can't hit breakpoints while attached to IIS process if you haven't logged into your Microsoft account in VS2017.

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

    My case is not mentioned here:
    I have to run the web project on a fake domain (settup on IIS and /hosts/etc) because of the callbacks from a third party site.

    I was seeing two w3wp processes in the process list of VS:
    w3wp.exe User Name: IIS APPPOOL\Default app pool
    w3wp.exe User Name: IIS APPPOOL.svc

    I had to to manually attach to second one to be able to debug.

    So I realised the app pool of my Fake domain in iis is not set to "Default app pool"

    https://manage.accuwebhosting.com/knowledgebase/2532/How-to-change-application-pool-from-IIS.html

    As soon as I changed the domain's app pool to the "Default app pool" visual studio started to debug the web app.

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

    The issue was resolved by unchecking the

    Properties > Build > Optimize Code

    setting on the web page properties screen (under General).

    Screenshot.

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

    Right click on your project, then left click Properties, and select the Web tab.

    Verify whether the correct server is selected for your case:

    • IIS Local

    • IIS Express

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

    If none of the above work, double-check your code. Sometimes the reason why the breakpoint appears to not be hitting is due to the block of code containing the breakpoint is not being executed for sometimes inadvertant reasons.

    For example, forgetting the "Handles Me.Load" has gotten me a few times when copying and pasting code:

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        --this block of code will not execute
        End Sub 
    

    vs

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        --this block executes
        End Sub
    
    0 讨论(0)
  • 2020-12-04 19:40

    I had the same issue in a Xamarin.Forms project. The fix was manually converting the PCL from .NET 4.6 to .NET Standard 2.0.

    PCL Advanced Build Configuration

    For Visual Studio Mac: make sure you do it for each project

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