Search code examples
c#visual-studio-2017vsixenvdte

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!


Solution

  • 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.