For SharePoint developers frustrated with attaching IIS processe to the debugger or are accustomed to debugging a webservice hosted in IIS, this article will help you speed up your development work or at least save a few minutes/seconds.Do you know that any process you need to repeat again and again can be automated in Visual Studio? How? Have you heard of Macros? Yes this is the key for winning this game and get a step ahead of other developers.Use the following to understand how to attach a process to a debugger:
Option Strict OffOption Explicit OffImports SystemImports EnvDTEImports EnvDTE80Imports EnvDTE90Imports System.DiagnosticsPublic Module IISDebugAttach Sub AttachDebuggerToIIS() Dim processToAttachTo As String = "w3wp.exe" If Not AttachToProcess(processToAttachTo) Then MsgBox(processToAttachTo & " is not running") End If End Sub Function AttachToProcess(ByVal processName As String) As Boolean Dim proc As EnvDTE.Process Dim attached As Boolean For Each proc In DTE.Debugger.LocalProcesses If (Right(proc.Name, Len(processName)) = processName) Then proc.Attach() attached = True End If Next Return attached End FunctionEnd Module
Now forget about the headache of attaching to an IIS process every time. Just press your shortcut key. (Make sure you're running your Visual Studio with administrator privilege.)Have fun. Cheers!!