views:

53

answers:

0

I am trying to create a macro in Visual Studio 2008 to attach to my local webdev server for an asp.net mvc project.

Here's the current macro code:

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Imports System.IO

Public Module Macros
    ' This subroutine attaches to the first Development Web Server found.'
    Public Sub AttachToFirstDevWebServer()
        Dim process As EnvDTE.Process

        For Each process In DTE.Debugger.LocalProcesses
            If (Path.GetFileName(process.Name).ToLower() = "webdev.webserver.exe") Then
                process.Attach()
                Exit Sub
            End If
        Next

        ' Better not have a class library as the startup or this will hang'
        DTE.Debugger.Go(False)
    End Sub

End Module

Sometimes, I don't catch that the startup project has been set to one of the class libraries. Starting the debugger manually in this scenario would pop up a modal window that I can dismiss. Then I can set the startup project properly. No big deal.

However, when starting the debugger in a macro, this window does not appear. It does play the alert sound. It doesn't get a tab in the task bar. I also cannot alt-tab to it.

At this point, the macro and the debugger hang. Visual Studio becomes almost unresponsive as well.

To recover from this I have to close VS, force quit the devenv32 process, restart VS, and then set the startup project properly.

How can I change the macro to handle this situation automatically?