In VS2010, is there a way to find out which application pool is being used for a given w3wp.exe and then decide to attach a debugger?

So, I am debugging some websites (one from the torso, one from the branch) running locally, in separate applications. I have solutions for trunks and branches open in duplicate VS. I would like to debug the trunk in one and the other in the other. I would like to know if there is a way to find out which application pool each w3wp.exe is running, so that I can see which one when attaching the debugger.

Update: The point here is to write a macro in VS to then give me a button (for an interesting application) that will be available to connect to a debugger. Therefore, solutions should preferably not include other programs.

Update2: This is on Windows 7 versus IIS7.

+1


a source to share


5 answers


Another option would be WADA - W3WP Advanced Attach , available in the Visual Studio Gallery. I found it by searching the Online Gallery of Extension Manager for "attach worker".



+1


a source


Below is my main macro. Write a few one-line subscribers calling this, for example AttachToW3wp("DefaultAppPool")

, naming each application pool you are interested in and making buttons and hotkeys for them.



    Private Sub AttachToW3wp(ByVal appPoolName As String)
    Const processName As String = "w3wp.exe"
    Dim userName As String = String.Format("IIS APPPOOL\{0}", appPoolName)

    Try
        Dim debugger As EnvDTE90.Debugger3 = CType(DTE.Debugger, EnvDTE90.Debugger3)
        'debugger.DetachAll()

        Dim transport As EnvDTE80.Transport = debugger.Transports.Item("Default")
        Dim qualifier As String = Environment.MachineName '= My.Computer.Name
        Dim engines(3) As EnvDTE80.Engine
        engines(0) = transport.Engines.Item("Managed")
        engines(1) = transport.Engines.Item("Script")
        engines(2) = transport.Engines.Item("T-SQL")

        Dim successMessage As String = String.Empty
        For Each process As EnvDTE80.Process2 In debugger.GetProcesses(transport, qualifier)
            With process
                Dim fi As New System.IO.FileInfo(.Name)
                If fi.Name = processName AndAlso (String.Compare(.UserName, 0, userName, 0, Len(userName), True) = 0) Then
                    If .IsBeingDebugged Then Throw New Exception(String.Format("{0} {1} is already attached to a debugger.", processName, userName))

                    process.Attach2(engines)
                    successMessage = String.Format("Attached to {0} for {1} ({2})", processName, userName, .ProcessID)

                    Exit For
                End If
            End With
        Next

        If successMessage = String.Empty Then
            Throw New Exception(String.Format("{0} {1} not found.", processName, userName))
        Else
            Trace.WriteLine(successMessage)
        End If

    Catch ex As System.Exception
        MsgBox(ex.Message)
    End Try
End Sub

      

+4


a source


Have a look at the answers to this question . There are built-in scripts that you can run from the command line to do this.

+1


a source


If you can execute the request in each branch, you can use something like Process Explorer or Task Manager to find out what the ID is, which is possible, since it is possible to tackle the CPU cycles that are currently processing the request, assuming you you can get such a separation.

0


a source


You can use the task manager to view the username under which the process is running (which is broadly the same as the application pool name) and the process ID, but you must enable these columns in the task manager and also the process name must be the same as the application pool (I know by default).
Also note that all of the methods listed on this page can only display the processes that are currently running, which means that if your particular process goes down due to downtime, you must first use the site to bring the process to list, and in your case, this means that you must first access all sites to ensure that the process associated with them is running.

-1


a source







All Articles