Reputation: 2555
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?
Upvotes: 5
Views: 2858
Reputation: 2555
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();
}
Upvotes: 7
Reputation: 32541
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();
// ...
}
Upvotes: 2
Reputation: 41
We are using OnAfterOpenProject. You can check for updates and bring up a dialog if found.
Upvotes: 0