2016-07-10

Remote Debug .NET Web Application with Visual Studio

.NET platform 的 remote debug 機制不像 Java 內建於 JVM,.NET CLR 並無內建此機制,需要在受測端安裝 agent (remote tools),控制端只要安裝 Visual Studio 即可。從 client/server 架構來看:

  • Server (受測端):需執行 Remote Debugging Monitor (msvsmon.exe) 與 IIS worker process (w3wp.exe)
  • Client (控制端):執行 Visual Studio
Note:
  • 基本上是 client/server 架構,client 執行 Visual Studio,server 要裝對應版本的 remote tools,預設 port 是 4016;版本不匹配可能會找不到或直接顯示版本錯誤的訊息。
  • 針對 web application 的 remote debug 要 Visual Studio 2005 以後的版本,2012 開始 Community Edition 也支援 remote debug。
  • Attach 的 process 是 IIS worker process (w3wp.exe),因為一台機器上可能同時跑多個 workers,確認 target process 可以參考 [1]
  • Authentication 只支援 Windows 認證,需要在 server side 與 client side 都建立相同的帳號;不然就是不認證 (no authentication; since Visual Studio 2012)。當使用 Windows 認證時,client side 需以 debugging 用的帳號執行 Visual Studio。
see also: