Quantcast
Viewing all articles
Browse latest Browse all 19

Create a macro for VS debugging instead of attach to process

Go to Tools -> Macro Explorer

Image may be NSFW.
Clik here to view.

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

Image may be NSFW.
Clik here to view.

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…

Image may be NSFW.
Clik here to view.

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)

Image may be NSFW.
Clik here to view.

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


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 19

Trending Articles