简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM