Gokul's Blog


Leave a comment

Macro to attach a process to Debug in Visual Studio

When we have to attach a process for debugging in Visual Studio we have to manually do it by navigating to the Debug menu ==> attach to process.

Here is the code which I tweaked a bit to automate this process.
Reference Url: http://consultingblogs.emc.com/howardvanrooijen/archive/2007/06/24/Attach-to-Web-Server-Macro-for-Visual-Studio.aspx

Code (this enhanced code also supports the Visual Studio built in cassini server)

Public Module AttachProcesstoDebug

    Public Sub AttachToWebServer()

        Dim AspNetWp As String = "aspnet_wp.exe"
        Dim W3WP As String = "w3wp.exe"
        Dim Webdev As String = "webdev.webserver.exe"
        If Not (AttachToProcess(Webdev)) Then
            If Not (AttachToProcess(AspNetWp)) Then
                If Not AttachToProcess(W3WP) Then
                    System.Windows.Forms.MessageBox.Show(String.Format("Process {0} or {1} Cannot Be Found", AspNetWp, W3WP), "Attach To Web Server Macro")
                End If
            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).ToLower() = ProcessName.ToLower()) Then
                Process.Attach()
                ProcessFound = True
            End If
        Next

        AttachToProcess = ProcessFound

    End Function
End Module


Leave a comment

Highlight open file in Solution Explorer, Immediate Window In VS-2008

Taken from: http://stackoverflow.com/questions/1671074/visual-studio-current-file-in-solution-explorer-make-it-darker

Check out Tools > Options > Projects and Solutions, and then check off "Track Active Item in Solution Explorer". This will make whichever file you’re viewing/editing inside of Visual Studio automatically be selected in Solution Explorer and if your Windows color scheme is set up properly, it will in fact be darker.

This option used to be on by default in 2003 and maybe 2005, but 2008 has it disabled by default now… I personally prefer it turned on.

 

Side Tip:

In Visual Studio 2008 if you want to view Immediate window Press Ctrl+Alt+I


Leave a comment

Todo List in Visual Studio

Add "Todo" in your comments and then you will be able to see the list of items using the Visual Studio menu item

View Menu  >> Task List (Ctrl+T, Ctrl+\). The window defaults to TaskList, change the drop down to Comments. You will see the list of Todo’s in that page.

If you have Resharper, though the file is closed you will be able to see the set of TODO’s.