2009-05-01 3 views

답변

1

첨부 할 프로세스를 알 수 있도록 프로세스의 identity을 변경하는 것이 좋습니다.

2

이 VS 매크로를 사용하여 응용 프로그램 이름을 기반으로 작업자 프로세스에 연결할 수 있습니다. 유일한 트릭은 Microsoft.Web.Administration.dll을 C : \ Windows \ System32 \ inetsrv에서 % 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 

:

Sub AttachToMyApp() 
    AttachToWorkerProcess("MyApp") 
End Sub 
관련 문제