Is it possible to get the process id of a visual studio instance through the DTE mDte variable? Refer to code below.
private static DTE mDte;
public static void OpenVisualStudio()
{
Type visualStudioType = Type.GetTypeFromProgID("VisualStudio.DTE.10.0");
mDte = Activator.CreateInstance(visualStudioType) as DTE;
if (mDte != null)
{
mDte.MainWindow.Visible = true;
}
// get process id of visual studio instance through mDte
}
I have done as follows :
public static int OpenVisualStudio()
{
var devenv = Process.Start("devenv.exe");
if (devenv == null)
{
return 0;
}
do
{
System.Threading.Thread.Sleep(2000);
mDte = GetDte(devenv.Id);
}
while (mDte == null);
return devenv.Id;
}
I got it from here: http://blogs.msdn.com/b/kirillosenkov/archive/2011/08/10/how-to-get-dte-from-visual-studio-process-id.aspx
It solves my problem for now...
DTE
对象具有Debugger
属性,该属性具有CurrentProcess
属性,该属性具有ProcessID
属性。
int processId = dte.Debugger.CurrentProcess.ProcessID;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.