Quantcast
Channel: Horizontal Integration » Uncategorized
Viewing all articles
Browse latest Browse all 19

Create a macro for VS debugging instead of attach to process

$
0
0

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

Process.Attach()

ProcessFound = True

End If

Next

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!!!



Viewing all articles
Browse latest Browse all 19

Trending Articles