I'm working on a VS extension that consist of a toolbar, a toolwindow and a settings page. The whole extension more or less works, but only after loading a solution. As the toolbar contains short-cuts to external applications, it would be favourable to be able to launch those applications already before loading the solution. The main package I set-up as follows:
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
[ProvideMenuResource("Menus.ctmenu", 1)]
[ProvideToolWindow(typeof(MyBarToolWindow))]
[ProvideOptionPage(typeof(UserSettingsPage), "My Toolbar", "Settings", 0, 0, true)]
[ProvideProfileAttribute(typeof(UserSettingsPage), "MyBar (new)", "General", 1002, 1003, true)]
[Guid(GroupsGuids.guidMyBarUIPkgString)]
[ProvideAutoLoad(UIContextGuids80.NoSolution, PackageAutoLoadFlags.BackgroundLoad)]
public sealed class MyBar_UIPackage : AsyncPackage, IDteServiceProvider
{
private IMyBarSettings settings;
// .....
/// <summary>
/// Called when the VSPackage is loaded by Visual Studio.
/// </summary>
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
// Switches to the UI thread in order to consume some services used in command initialization
await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
await base.InitializeAsync(cancellationToken, progress);
this.GetDte().Events.DTEEvents.OnStartupComplete += this.OnStartupCompleted;
this.GetDte().Events.SolutionEvents.Opened += this.OnInitialize;
this.GetDte().Events.WindowEvents.WindowActivated += this.OnWindowEventsWindowActivated;
// Query service asynchronously from the UI thread
var dte = GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
}
}
Somehow Opened
WindowActivated
and OnStartupComplete
don't fire during startup of Visual Studio, but only while loading a solution.
Why is that and how can I force the extension to be started with VS?
EDIT: just found out, if I close VS with the toolwindow open, it gets reopened upon next start-up and with that, the extension starts as well. If VS starts up without the toolwindow open, I can't even open the toolwindow because the extension is not yet started-up (hence: loading a solution is necessary).