Deltax76
Deltax76

Reputation: 14263

How to automatically attach VS to another process for debugging?

I'm debugging an ASP.NET application deployed on IIS 7.5 (VS 2010/Windows 7 x64) . After I make changes, I have to deploy it to the IIS folder and then do the following things (anyone of you should already know, I just list to demonstrate how boring and time-consuming they are):

well, it's load of unnecessary works. Due to our system architect, this is the only way, we can debug straightforward by F5 button, but I wonder that if there's a workaround about this, so I can do all these things in on-click or short-cut key.

Thank you very much.

Upvotes: 3

Views: 3296

Answers (2)

Alex Aza
Alex Aza

Reputation: 78487

Why don't you just go to project properties and select Use Local IIS Web Server.

enter image description here

If this is remote server you can do this too: Using Visual Studio 2008 with IIS 7
Although the article is about VS2008, the concept is the same in 2010.

Upvotes: 3

Fourth
Fourth

Reputation: 9351

http://blog.lavablast.com/post/2008/01/11/Attach-to-Process-with-one-shortcut.aspx

Create a macro in visual studio with the following:

Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Imports System.Security.Principal

Public Module RecordingModule
    Sub AttachToAspNET()
        Try
            Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
            Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
            Dim compName As String = WindowsIdentity.GetCurrent().Name
            compName = compName.Substring(0, compName.IndexOf("\"))
            Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, compName).Item("w3wp.exe")
            proc2.Attach2(dbgeng)
        Catch ex As System.Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Module 

change w3wp.exe to aspnet if thats what you want. Then go into the key shortcuts and just bind a shortcut to run that macro.

Upvotes: 7

Related Questions