Disable add-in from VSIX package RRS feed

  • Question

  • I trying to disable an add-in when my package is initialized

    EnvDTE80.DTE2 dte2 = (EnvDTE80.DTE2)GetService(typeof(EnvDTE.DTE));
    foreach (EnvDTE.AddIn addin in dte2.AddIns)
        if (addin.ProgID.Equals("MyAdddin.Connect"))
            addin.Connected = false;

    That seems to correctly disable the add-in as if you have unchecked the "Available Add-ins" column in the add-in manager, but when VS restart the add-in is enabled, any ideas how to make this change persistent?

    I have other issue with this approach my package uses auto-load 


    So the add-in doesn't get disabled until a solution opens, is there a way to get my package loaded after VS start even without solution, I see there is UIContextGuids80.NoSolution but isn't activate when VS just starts without a solution/project loaded.

    Friday, March 27, 2015 10:34 AM


  • [ProvideAutoLoad(VSConstants.UICONTEXT.NoSolution_string)]

    should load your package even if a solution is not loaded. Do not mix it with other ProvideAutoLoad values.

    Regarding the add-in question, to mark an add-in not to load on startup there is no API, you need to modify:

    - If the add-in uses COM-registration, the LoadBehavior=0 name/value in the registry key where it is registered.

    - If the add-in uses XML-registration (.AddIn file), you need to locate the .AddIn file and modify the <LoadBehavior>0</LoadBehavior> tag value.

    Notice that in both cases, if the add-in is registered for all users (and not for the current user), administrator rights will be required, and your package will lack them because since VS 2008 the IDE is launched without admin rights by default. So you may want to revisit your approach and maybe just show a warning to the user to make her to unload/uninstall the add-in if your package detects that the add-in is loaded. Or make your package compatible with the add-in and do nothing else.

    * My new blog about VSX: http://www.visualstudioextensibility.com * Twitter: https://twitter.com/VSExtensibility * MZ-Tools productivity extension for Visual Studio: http://www.mztools.com.

    Friday, March 27, 2015 11:06 AM