0

Code's like below, similar to the built-in Custom Tool Window code template. To load the package I have to find the ToolWindow button (Command) and press it. When I open up a folder this package is not loaded. However this extension depends on evnets provided by some services (IVsFileChangeEx, .etc), and they needed to be loaded by AsyncPackage.GetServiceAsync. What should I do?

[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[Guid(Guids.packageGuidStr)]
[ProvideMenuResource("Menus.ctmenu", 1)]
[ProvideToolWindow(typeof(ToolWindow))]
public sealed class ExuedPackage : AsyncPackage
{
    protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
    {
        await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

        "Init Package".Log();

        .... Get some services and store them ...
        .... Register callbacks to them ....

        await ToolWindowCommand.InitializeAsync(this);
    }
}
karatoga
  • 513
  • 4
  • 14
  • Possible duplicate of [Visual Studio Extensibility: ProvideAutoLoad for Package.cs for every UI Context](https://stackoverflow.com/questions/27687954/visual-studio-extensibility-provideautoload-for-package-cs-for-every-ui-context) – Simon Mourier Jul 12 '19 at 10:02
  • @SimonMourier A warning says ProvideAutoLoad tends to be deprecated, and there's also warning that advices turning off this kind of extension in vs2019... – karatoga Jul 12 '19 at 10:09
  • 1
    Use ProvideAutoLoad as a starting point for our google search: https://devblogs.microsoft.com/visualstudio/improving-the-responsiveness-of-critical-scenarios-by-updating-auto-load-behavior-for-extensions/ – Simon Mourier Jul 12 '19 at 10:23

0 Answers0