Visual Studio Debugger RPC Extension#
Of course after writing all this, it soon became obvious that there were better ways. Here's the C# equivalent:
C#
using EnvDTE;
namespace AttachDebugger
{
class Program
{
static void Main(string[] args)
{
try
{
DTE dte = (DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.10.0");
dte.ExecuteCommand("Macros.StarVSMacros.Debug.AttachToGame");
}
catch (System.Exception e)
{
System.Windows.Forms.MessageBox.Show("EXCEPTION - Debugger not available: " + e.Message);
}
}
}
}
This is the version I ended up using. All it needs is a reference to EnvDTE added to your C# project to compile.
Some references: