5

I am building a Visual Studio extension and I am stumped on how I would show a dialog when visual studio is started.

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.

Information on extensions is very scarce so I have no idea how to do this. I am using 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. 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?

user1632018
  • 2,485
  • 10
  • 52
  • 87
  • Visual Studio already has a mechanism for detecting updated extensions. Why is it not useful for your needs? – Jason Malinowski Feb 28 '13 at 20:38
  • 2
    Because that only works if the extension is in the MS gallery, and sometimes you don't want/need your extension in the gallery (I.e. internal company tool of some form, which has no use outside your production environment), which I don't think you can get VS to pickup on updates for extensions installed via the .vmx file. – Psytronic Feb 28 '13 at 20:45

3 Answers3

7

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. The reason why it was not working was because the DTE object wasn't initialized at that point. 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();

    }
user1632018
  • 2,485
  • 10
  • 52
  • 87
2

I'm assuming you are using a Visual Studio Add-in project. If you want just a message box, in the Connect.cs file, add a reference to System.Windows.Forms and a using statement:

using System.Windows.Forms;

In the OnConnection method:

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();

    // ...
}
Alex Filipovici
  • 31,789
  • 6
  • 54
  • 78
0

We are using OnAfterOpenProject. You can check for updates and bring up a dialog if found.