Ver versión en español    
 
Home
10 Reasons to use MZ-Tools
MZ-Tools 6.0 for VS.NET
Editions
Features
Online Documentation
MZ-Tools SDK
Download
Purchase
Version History (RSS)  
FAQ & Support
MZ-Tools 3.0 for VB6 & VBA
Features
Online Documentation
Download (freeware)
Donations (Paypal)
Version History (RSS)  
FAQ & Support
User Reviews
Community Place
Contact  
For Add-In Developers
About
   
 
User Testimonials

I'm an avid supporter of MZ-Tools. It's a product I couldn't do without and your level of support is outstanding.

Jan Hyde (Visual Basic MVP)

You will soon wonder how you ever lived without it.

Andy Maggs

More user reviews
 
HOWTO: Reset a Visual Studio add-in

Author: Carlos J. Quintero (Microsoft MVP) Applies to: Microsoft Visual Studio .NET 2002
Date: February 2006   Microsoft Visual Studio .NET 2003
      Microsoft Visual Studio 2005
Introduction

This article explains how to reset the commands and user interface of a Visual Studio .NET add-in.

More Information

An add-in typically create its commands when it receives the ext_cm_UISetup flag in the connectMode parameter of the OnConnection method, and this happens only once in the whole lifetime of the add-in. An add-in that uses commands uses a CommandPreload=1 registry entry value (for add-ins using Registry registration) or XML entry (for Visual Studio 2005 add-ins using XML registration). That value indicates to Visual Studio that the add-in uses commands and therefore the ext_cm_UISetup flag should be used once. Visual Studio .NET uses different locations to store if that flag has been already used:

  • For Visual Studio .NET 2002/2003 add-ins registered only for the current user (HKEY_CURRENT_USER registry hive):

    HKCU\Software\Microsoft\VisualStudio\<version>\Addins\<MyAddin>\CommandPreload

    where:

    <version> = 7.0 for Visual Studio .NET 2002
    <version> = 7.1 for Visual Studio .NET 2003
    <version> = 8.0 for Visual Studio 2005

    A CommandPreload value of 1 indicates that the ext_cm_UISetup flag will be used for that add-in the next time that Visual Studio .NET starts and a value of 2 indicates that the flag was already used.
  • For Visual Studio .NET 2002/2003 add-ins registered for all users (HKEY_LOCAL_MACHINE registry hive):

    HKCU\Software\Microsoft\VisualStudio\<version>\PreloadAddinState\<MyAddIn>

    While the CommandPreload registry entry is stored in the HKEY_LOCAL_MACHINE registry hive, since the state must be stored per user, the HKEY_LOCAL_MACHINE registry hive can not be used and this one is used instead.
  • For Visual Studio 2005 add-ins:

    HKCU\Software\Microsoft\VisualStudio\8.0\PreloadAddinStateManaged\<MyAddIn>

So, you can force a new ext_cm_UISetup phase just by altering the value indicated above. That will not delete the commands of the add-in, though.

If you want to completely reset the IDE, you can use the following procedure:

  • Close all IDE instances.
  • Open a Visual Studio .NET Command Prompt ("Run...", "Programs", "Visual Studio .NET", "Visual Studio .NET Tools", "Visual Studio .NET Command Prompt")
  • Type:

    devenv.exe /reset

That will delete all the commands of all the add-ins and their permanent commandbars, buttons, etc., resetting also their PreloadAddinState value. So, the next time that the IDE starts, they will receive the ext_cm_UISetup flag.

Notice that using the /reset flag causes also some undesirable effects in the IDE since some user customizations are lost too, specially in Visual Studio .NET 2002.

Visual Studio 2005 offers a new less drastic method to reset an add-in. To reset a specific add-in you can use:

devenv.exe /resetaddin Namespace.Class

where Namespace.Class is the fully qualified name of the main class of the add-in (the Connect class). If you create a Visual Studio 2005 add-in and you go to its properties pages, Debug section, you will notice that there is a command line argument of the form /resetaddin MyAddin.Connect. That gives to the add-in the chance of regenerating its commands each time you debug it. You can use this approach to remove the commands of the add-in when it is uninstalled: if you delete the registry entries and/or XML file and then you execute the above statement, the commands of the add-in will be deleted, and since the add-in is uninstalled there will not be a new ext_cm_UISetup phase for it.

To reset all add-ins you can use:

devenv.exe /resetaddin *

Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this

MZ-Tools 6.0 for Visual Studio .NET

You can code, design, locate code and document your apps much faster using VB.NET, C#, C++ or Visual J#:

Buy MZ-Tools Now Download MZ-Tools Demo

   Top