Tuesday, 4 October 2011

How to: Macro for attaching to w3wp.exe

Use the macro below to attach your debugging engine in Visual Studio 2008 to the IIS worker process.

(Note: have updated this to dynamically pick up the Machine name from the System.Environment class.)

    Sub AttachToW3p()

        Try
            Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
            Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
            Dim dbgeng(1) As EnvDTE80.Engine
            dbgeng(0) = trans.Engines.Item("Managed")
            Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, System.Environment.MachineName).Item("w3wp.exe")
            proc2.Attach2(dbgeng)
        Catch ex As System.Exception
            MsgBox(ex.Message)
        End Try

    End Sub

No comments:

Post a Comment

How to find the last interactive logons in Windows using PowerShell

Use the following powershell script to find the last users to login to a box since a given date, in this case the 21st April 2022 at 12pm un...