Odrai
Odrai

Reputation: 2353

ExtensionManager null in Visual Studio 2017

In previous versions of Visual Studio I could use the following code to retrieve information about a certain installed extension (vsix):

IVsExtensionManager manager = ServiceProvider.GlobalProvider.GetService(typeof(SVsExtensionManager)) as IVsExtensionManager;
if (manager != null)
{
    VsExtension extension = new VsExtension();
    IInstalledExtension info = manager.GetInstalledExtension(cExtensionProductId);
}

In the new Visual Studio 2017 version, the 'manager' variable is always null. Microsoft changed the way to retrieve the information (they no longer use the system registry), but I can't find another way to retrieve the info.

Do you know where I can find more information and/or provide a sample of the new implementation?

Thank you in advance!

Upvotes: 3

Views: 1090

Answers (2)

Oleg Skripnyak
Oleg Skripnyak

Reputation: 311

Is the ServiceProvider.GlobalProvider.GetService(typeof(SVsExtensionManager)) returns null ? or "as IVsExtensionManager" becomes null ?

Upvotes: 0

Sergey Vlasov
Sergey Vlasov

Reputation: 27880

Please check that for VS 2017 you are using VS 2017 specific references to the extension manager. It should be Microsoft.VisualStudio.ExtensionManager.dll and Microsoft.VisualStudio.ExtensionEngine.dll.

For a working example see https://vlasovstudio.com/visual-commander/commands.html#ExtensionsList.

Upvotes: 2

Related Questions