Create a macro for VS debugging instead of attach to process

Go to Tools -> Macro Explorer

Right click on “MyMacros” and select “New Module” and name it “RecordingModule”

Copy this code in there:

Option Strict OffOption Explicit OffImports System

Imports EnvDTE

Imports EnvDTE80

Imports EnvDTE90

Imports System.Diagnostics

Imports System.Security.Principal

Public Module RecordingModule

Sub AttachToAspNET()

Dim AspNetWp As String = “aspnet_wp.exe”

Dim W3WP As String = “w3wp.exe”

If Not (AttachToProcess(W3WP)) Then

If Not AttachToProcess(AspNetWp) Then

System.Windows.Forms.MessageBox.Show(“Can’t find web server process”)

End If

End If

End Sub

Public Function AttachToProcess(ByVal ProcessName As String) As Boolean

Dim Processes As EnvDTE.Processes = DTE.Debugger.LocalProcesses

Dim Process As EnvDTE.Process

Dim ProcessFound As Boolean = False

For Each Process In Processes

If (Process.Name.Substring(Process.Name.LastIndexOf(“\”) + 1) = ProcessName) Then


ProcessFound = True

End If


AttachToProcess = ProcessFound

End Function

End Module

Save it…

Go to Tools -> Options -> Environment -> Keyboard

Type in AttachToAspNET and put your shortcut into “Press shortcut keys” and click assign and click ok.

I used Ctrl+Shft+` (back tick)

Now you can click this when you want to debug, but it needs to be made smarter if you have two Sitecore sites open so it knows which w3wp.exe to attach to.

Special Thanks to Mike!!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: