title: How to get a programmable interface to the Visual Studio Call Stack window?
body: <p>I am working on a Visual Studio add-in (part of the ILSpy open source project) and I want to get information about the currently selected stack frame in the Visual Studio Call Stack window.</p>
  
  <p>I tried this:</p>
  
  <pre><code>var callstackWindow = ((EnvDTE80.DTE2)GetGlobalService(typeof(EnvDTE.DTE))).ToolWindows.GetToolWindow("Call Stack");
  </code></pre>
  
  <p>However it throws an exception when not debugging (and Call Stack window not present) and returns null when the Call Stack window is present.</p>
  
  <p>There is a vsWindowTypeCallStack member in the <a href="https://msdn.microsoft.com/en-us/library/envdte.vswindowtype.aspx" rel="nofollow">vsWindowType enumeration</a>, but I can't find any API that uses it. I've searched the EnvDTE documentation without finding any further information.</p>
  
  <p>I'm working in C# with Visual Studio 2013 Professional.</p>