For debugging class libraries, web services etc., we may need to attach the debugger to a running ASP.NET process.
It is better to write a macro to accomplish the above and use it for any number of times using a simple Key press (with your own key combination). Following are the steps to achieve the same:
- Open Visual Studio 2005
- Press Alt-F8 to bring up Macro Explorer
- Add a new Module (AttachProcessToWeb) and type in the code as following:
Imports System Imports EnvDTE Imports EnvDTE80 Imports System.Diagnostics Imports EnvDTE90 Imports System.IO Public Module AttachProcessToWeb Public Sub AttachProcess() Dim process As EnvDTE.Process For Each process In DTE.Debugger.LocalProcesses If (Path.GetFileName(process.Name).ToLower() = "aspnet_wp.exe") Then process.Attach() Exit Sub End If Next MsgBox("No ASP.NET Development Server found") End Sub End Module
- Configure Keyboard shortcut using Tools || Options as following: