Skip to content

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:

From https://github.com/dwilliamson/b/blob/623a4882561c0893e01488730896c6660794e257/Posts/2012-02-07-11-37-23.txt