killika
killika

Reputation: 72

How to Bootstrap an VSIX VS2015 Extension

My extension only gets called if I click on a button. Only than the ctor CommandHandlerPackage is called and the CommandMenu items are registered.

But I want to DefaultDisable the Buttons and only enable them if I open the right Solution. To do that I need to register some Events from IVsSolutionEvents but I cant do this from the begining because the extension is initialized only if I interact with it.

So my question is is there something like a bootstrap for this scenario?

Upvotes: 1

Views: 183

Answers (1)

Mads Kvist Kristensen
Mads Kvist Kristensen

Reputation: 2620

You can add the ProvideAutoLoad attribute to your Package class like so:

[ProvideAutoLoad(UIContextGuids80.SolutionExists)]
public sealed class VSPackage : Package
{
  ...
}

This will automatically run the Initialize method of your package class when a file or project is open.

Upvotes: 1

Related Questions