简体   繁体   English

如何显示使用 EnvDTE 创建的 Visual Studio 进程

[英]How can I show visual studio process created using EnvDTE

I have an app that can help to explore, generate and open visual studio projects.我有一个应用程序可以帮助探索、生成和打开 Visual Studio 项目。 I'm creating the visual studio process using the Activator method as follows:我正在使用 Activator 方法创建 Visual Studio 进程,如下所示:

using System;
using System.Windows.Forms;
using EnvDTE80;
using System.Runtime.InteropServices;

namespace TestWindowsApp
{
    static class Program
    {
        [DllImport("user32.dll")]
        private static extern bool SetForegroundWindow(IntPtr hWnd);

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Type type = Type.GetTypeFromProgID("VisualStudio.DTE.14.0");
            DTE2 dte = (DTE2)Activator.CreateInstance(type, true);

            dte.MainWindow.Visible = true;
            dte.UserControl = true;
            SetForegroundWindow((IntPtr)dte.MainWindow.HWnd);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

It works great except the process it creates is hidden.除了它创建的过程被隐藏之外,它工作得很好。 If I use Process Explorer's "Find Window's Process" feature I get the error:如果我使用 Process Explorer 的“Find Window's Process”功能,我会收到错误消息:


Process Explorer Error进程资源管理器错误

The owning process is devenv.exe (process ID 22196), which is not currently visible in the process list.拥有进程是 devenv.exe(进程 ID 22196),当前在进程列表中不可见。

OK好的

Is there any way to use this method but make the process visible?有什么方法可以使用此方法但使过程可见? It makes working with the spawned visual studio a bit harder than if you open it manually.与手动打开它相比,它使使用衍生的 Visual Studio 变得更加困难。

尝试文件 > 显示所有进程的详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用EnvDTE在visual studio中添加文件链接 - How to add a link to a file in visual studio using EnvDTE 使用EnvDTE自动化Visual Studio - Automating Visual Studio with EnvDTE 使用EnvDTE以编程方式更改Visual Studio项目的Debug属性 - Change Debug property of a Visual Studio project programmatically using EnvDTE Visual Studio 2008和2008 SP1加载项:使用EnvDTE90和EnvDTE90a - Visual Studio 2008 and 2008 SP1 Addin: using EnvDTE90 and EnvDTE90a 确定Visual Studio中打开的选项卡的顺序(使用EnvDTE进行扩展) - Determining the order of open tabs in Visual Studio (extension using EnvDTE) Visual Studio 2017-如何从ENVDTE获取当前运行的版本 - Visual Studio 2017 - How to get the current running edition from ENVDTE 如何检查进程是否由 Visual Studio &gt; 2015 启动 - How can I check if a process was started by Visual Studio > 2015 如何附加到 Visual Studio Code 中的特定进程 - How can I attach to a specific process in Visual Studio Code "如何在 Visual Studio 中使用 .NET 5(独立进程)调试 Azure Functions?" - How can I debug Azure Functions using .NET 5 (isolated process) in Visual Studio? 我如何知道 Visual Studio 解决方案是由哪个版本的 Visual Studio 创建的? - How can I know which version of Visual Studio a Visual Studio solution is created by?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM