简体   繁体   English

如何在启动Visual Studio时显示对话框。 - VS扩展

[英]How to make a dialog appear when Visual Studio is started. - VS Extension

I am building a Visual Studio extension and I am stumped on how I would show a dialog when visual studio is started. 我正在构建一个Visual Studio扩展,我对如何在Visual Studio启动时显示对话框感到难过。

The main use for it is going to be when Visual studio starts my extension will check for updates if an update is found a dialog appears. 它的主要用途是当Visual Studio启动时,我的扩展将检查更新,如果发现更新,则会出现一个对话框。

Information on extensions is very scarce so I have no idea how to do this. 有关扩展的信息非常稀缺,所以我不知道如何做到这一点。 I am using C#. 我正在使用C#。

Edit: I have tried adding the code in the package file that has all of the command code/callbacks into it's initialize event and it shows the dialog before visual studio appears to have even loaded and does not continue to load until I close it. 编辑:我已经尝试将包含所有命令代码/回调的包文件中的代码添加到它的初始化事件中,它在visual studio看起来甚至已加载之前显示对话框,并且在我关闭之前不会继续加载。 I feel like I am getting closer though. 我觉得我越来越近了。

Is their an extension start up command I can create in VSCT file, kind of like they have for menu items? 他们是一个扩展启动命令,我可以在VSCT文件中创建,有点像菜单项吗?

I was able to figure out my problem. 我弄清楚了我的问题。 It took alot of trial and error due to the lack of info. 由于缺乏信息,它经历了大量的试验和错误。 I had originally tried the OnStartupcomplete() event but it was not working for me, hence I came here. 我最初尝试过OnStartupcomplete()事件,但它不适用于我,因此我来到这里。 The reason why it was not working was because the DTE object wasn't initialized at that point. 它不起作用的原因是因为DTE对象在那时没有被初始化。 So I was able to create the object and add the handler. 所以我能够创建对象并添加处理程序。

[ProvideAutoLoad(Microsoft.VisualStudio.Shell.Interop.UIContextGuids.NoSolution)]
[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExists_string)]

 protected override void Initialize()
    {
       //DTE gets called
        var dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
        _EventsObj = dte.Events.DTEEvents;
        _EventsObj.OnStartupComplete += OnStartupComplete;

    }

        public void OnStartupComplete()
    {
        //This is the code to launch the dialog.


        EvaluationDialog EvalForm = new EvaluationDialog();
        EvalForm.ShowDialog();

    }

I'm assuming you are using a Visual Studio Add-in project. 我假设您正在使用Visual Studio加载项项目。 If you want just a message box, in the Connect.cs file, add a reference to System.Windows.Forms and a using statement: 如果只需要一个消息框,请在Connect.cs文件中添加对System.Windows.Forms的引用和using语句:

using System.Windows.Forms;

In the OnConnection method: OnConnection方法中:

public void OnConnection(object application, 
    ext_ConnectMode connectMode, 
    object addInInst, ref Array custom)
{
    MessageBox.Show("message box");

    // or you could use your on dialog class
    var myDialog=new MyDialog();
    myDialog.Show();

    // ...
}

We are using OnAfterOpenProject. 我们正在使用OnAfterOpenProject。 You can check for updates and bring up a dialog if found. 您可以检查更新并在找到时打开对话框。

暂无
暂无

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

相关问题 如何制作清单 <Object> 在Visual Studio中使用WPF时,变量是否出现在DataBinding UI中? - How to make List<Object> variable appear in DataBinding UI when using WPF in Visual Studio? 在带有C#的Visual Studio中,如何在键入时自动显示(),例如.Focus()? - In Visual Studio with C#, how do I make the () appear automatically when I type, such as .Focus()? 如何在Visual Studio中正确显示MVC项目? - How do I make a MVC project appear properly in Visual Studio? 如何使我的自定义类型出现在Visual Studio设置编辑器中? - How to make my custom type to appear in Visual Studio Settings Editor? 是否可以在 Visual Studio 扩展中创建类似于 Intellisense 对话框的模式对话框? - Is it possible to create a modal dialog similar to the Intellisense dialog in a Visual Studio extension? 如果使用不同的VS编译,Visual Studio Extension无法正常工作 - Visual Studio Extension not working if compile with different VS Visual Studio发布对话框需要很长时间才能显示 - Visual Studio publish dialog taking a long time to appear Windows窗体的扩展并使它成为Visual Studio的一部分 - Extension of a Windows Form and make it part of Visual Studio 如何从 VS 扩展中引发 Visual Studio 错误(破坏构建过程)? - How to raise Visual Studio errors (that break the build process) from a VS extension? “无法启动此应用程序。” 仅当文件在 system32 目录中时 - “This application could not be started.” Only when the file is in system32 directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM