程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> 關於.NET >> 利用宏自動附加到WebServer進程

利用宏自動附加到WebServer進程

編輯:關於.NET

如果你像我一樣經常需要利用"attached to process "來完成對網站應用程序的調試,那麼你可能需要下面的宏來節省一點時間。

01: Imports System
02: Imports EnvDTE
03: Imports EnvDTE80
04: Imports EnvDTE90
05: Imports System.Diagnostics
06:
07: Public Module Debugger
08:   Public Sub AttachToWebServer()
09:
10:     Dim AspNetWp As String = "aspnet_wp.exe"
11:     Dim W3WP As String = "w3wp.exe"
12:
13:     If Not (AttachToProcess(AspNetWp)) Then
14:       If Not AttachToProcess(W3WP) Then
15:         System.Windows.Forms.MessageBox.Show(String.Format("Process {0} or {1} Cannot Be Found", AspNetWp, W3WP), "Attach To Web Server Macro")
16:       End If
17:     End If
18:
19:   End Sub
20:
21:   Public Function AttachToProcess(ByVal ProcessName As String) As Boolean
22:
23:     Dim Processes As EnvDTE.Processes = DTE.Debugger.LocalProcesses
24:     Dim Process As EnvDTE.Process
25:     Dim ProcessFound As Boolean = False
26:
27:     For Each Process In Processes
28:       If (Process.Name.Substring(Process.Name.LastIndexOf("\") + 1) = ProcessName) Then
29:         Process.Attach()
30:         ProcessFound = True
31:       End If
32:     Next
33:
34:     AttachToProcess = ProcessFound
35:
36:   End Function
37:
38: End Module
39:

出處:http://zhangronghua.cnblogs.com

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved