2009-05-01 30 views

Trả lời

1

Có thể tốt hơn để thay đổi số identity của quy trình để bạn biết cần đính kèm cái nào.

2

Bạn có thể sử dụng macro VS này để đính kèm với quy trình công nhân dựa trên tên ứng dụng. Bí quyết duy nhất là bạn cần sao chép Microsoft.Web.Administration.dll từ C: \ Windows \ System32 \ inetsrv thành% PROGRAMFILES (x86)% \ Microsoft Visual Studio 10.0 \ Common7 \ IDE \ PublicAssemblies.

Private Sub AttachToWorkerProcess(ByVal appName As String) 
    Dim targetPid = FindPoolPIDByName(appName) 
    If targetPid = -1 Then 
     MessageBox.Show("Unable to find a worker process hosting " + appName) 
    End If 

    Dim processes As EnvDTE.Processes = DTE.Debugger.LocalProcesses 

    For Each proc As EnvDTE.Process In processes 
     If proc.ProcessID = targetPid Then 
      proc.Attach() 
     End If 
    Next 

End Sub 

Private Function FindPoolPIDByName(ByVal appName As String) As Integer 
    Dim sm As New Microsoft.Web.Administration.ServerManager() 

    Dim appPoolName As String = Nothing 
    For Each site In sm.Sites 
     For Each app In site.Applications 
      If String.Equals(app.Path, "/" & appName, StringComparison.OrdinalIgnoreCase) Then 
       appPoolName = app.ApplicationPoolName 
      End If 
     Next 
    Next 

    If appPoolName Is Nothing Then 
     MessageBox.Show("Unable to find application " & appName) 
    End If 

    For Each wp In sm.WorkerProcesses 
     If wp.AppPoolName = appPoolName Then 
      Return wp.ProcessId 
     End If 
    Next 
    Return -1 
End Function 

Sau đó:

Sub AttachToMyApp() 
    AttachToWorkerProcess("MyApp") 
End Sub 
Các vấn đề liên quan