Visual Studio 2008 macro only works from the Macro IDE, not the Macro Explorer
Posted
by Cat
on Stack Overflow
See other posts from Stack Overflow
or by Cat
Published on 2009-07-29T19:22:15Z
Indexed on
2010/05/31
18:43 UTC
Read the original article
Hit count: 512
Edit: Creating a new module in the same VSMacros project fixed the problem.
The following macro only works if I open the Macro IDE from Visual Studio and run the macro from there.
It'd be much more useful if I could just right click the macro from the Macro Explorer from my Visual Studio instance.
I must be doing something obviously wrong, but I've never worked with VS macros before. The MessageBox does not appear in either case.
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Imports System.Security.Principal
Imports System.Windows.Forms
Public Module AttachToSdtProcess
Sub AttachToSdtProcess()
Try
'If MessageBox.Show("Attach to SDT.exe", "Caption", _
' MessageBoxButtons.OKCancel) = DialogResult.Cancel Then
'Return
'End If
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("TheExecutable.exe")
If proc2 Is Nothing Then
MessageBox.Show("Could not find TheExecutable.exe")
End If
proc2.Attach2(dbgeng)
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
End Module
© Stack Overflow or respective owner