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
FAQ & Support
Version History
MZ-Tools 3.0 for VB6 & VBA
Features
Online Documentation
Download (freeware)
Donations (Paypal)
FAQ & Support
Version History
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: Troubleshooting Visual Studio and Office add-ins

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

This article provides information to troubleshoot common problems of add-ins for Visual Studio or Office applications (shared add-ins).

More Information

These are common problems that can happen on the machine of the developer or on the machine of the final user, in this order:

1. The add-in is not registered for the host application

The host application can be Visual Studio or some Office application, depending on the target of the add-in. The first thing to check when an add-in does not work is that the add-in is registered for the host application.

There are two scopes of registration:

  • For all users (machine level)
  • For the user who installed the add-in (user level)

When you run the wizard to create the initial code of the add-in, you are asked the scope of the registration, for example with a checkbox with the phrase "My add-in should be available to all users of the computer it was installed on, not just the person who install its". It is recommended that you register the add-in for all users (machine level) because in many organizations the person installing the add-in is an administrator, different to the person who is going to use the add-in. 

There are two mechanisms of registration:

  • COM registration (Visual Studio .NET 2002, 2003, 2005 and Office applications):
    • The DLL must be registered as an ActiveX (COM) component.
    • The add-in must be registered for the host application using a registry entry in the hive HKEY_LOCAL_MACHINE (for all users) or HKEY_CURRENT_USER (current user). For example:

      For Microsoft Frontpage, user who installed the add-in:
      HKEY_CURRENT_USER\Software\Microsoft\Office\FrontPage\Addins\MyAddIn.Connect

      For Microsoft Visual Studio .NET 2003, all users:
      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.1\Addins\MyAddIn.Connect

      Where MyAddIn.Connect is the ProgId of the Connect class of the add-in. The host application locates registered add-ins checking its "AddIns" registry entries (in both HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER hives), getting the ProgIds, going to the HKEY_CLASSES_ROOT to locate the ProgID, getting its CLSID (such as {449E0007-4AB0-4C95-9FE1-EB442BB24FDF}) and going to HKEY_CLASSES_ROOT\CLSID\<clsid>\InprocServer32 to retrieve the path to the physical dll of the add-in.
  • XML registration (only Visual Studio 2005):
    • A XML file with the extension .AddIn must be placed in one of the folders listed in the "Tools", "Options" window, "Environment", "Add-In/Macros Security" section. Some of the folders are for all users (such as %ALLUSERSPROFILE%\Application Data\Microsoft\MSEnvShared\AddIns) while others are only for the current user (such as "%VSMYDOCUMENTS%\AddIns, where %VSMYDOCUMENTS% refers to the folder "Visual Studio 2005\Addins" inside the Documents folder of the user).
    • The XML file has an <Assembly> tag whose value is the location of the assembly of the add-in. Your setup must set this value after the user has selected an installation folder.

For Visual Studio add-ins, you can check if the add-in is registered through the Add-In Manager ("Tools", "Add-In Manager"), which shows all registered add-ins (COM or XML, for all users or for the current user).

For Office applications, the Add-In Manager for COM add-ins varies from application to application (notice that Office applications offer COM-addins and add-ins that are not COM-based):

  • For Microsoft Frontpage 2003, go to the "Tools", "Add-ins" menu.
  • For Microsoft Word 2003, go to the "Tools", "COM Add-ins" menu.
  • For Microsoft Outlook 2003, go to the "Tools", "Options" window, "Other" tab, "Advanced Options" button, "COM Add-Ins" button.
  • For Microsoft Excel 2003, follow the instructions of the link above.

So, if your add-in does not appear in the Add-In Manager of the host application the cause could be:

  • It is is an add-in registered only for the user who installs it (rather than an add-in registered for all users) and the person installing it is not the same than the person using it.
  • It is a COM add-in and the setup did not register it as a COM component. Notice that on the development machine, the add-in wizard registers the add-in for COM, but on the deployment machine your setup must do it.
  • It is a COM add-in but it is not registered for the host application. Notice that on the development machine, the add-in wizard creates these entries, but on the deployment machine your setup must do it.
  • It is a XML-based Visual Studio 2005 add-in but the XML file is not in one of the folders where Visual Studio 2005 locates add-ins (which are listed in the "Tools", "Options" window, "Environment" section, "Macros/Add-Ins Security). Notice that on the development machine, the add-in wizard creates that file, but on the deployment machine your setup must do it.
  • It is a XML-based Visual Studio 2005 / 2008 add-in but the <assembly> tag of XML file does not specify the correct location of the assembly Dll.
  • It is a XML-based Visual Studio 2005 / 2008 add-in but <HostApplication>\<Version> tag does not match the actual version of the IDE (8.0 for Visual Studio 2005, 9.0 for Visual Studio 2008).
  • It is a COM add-in for Office registered for all users (machine level). Office does not show COM add-ins registered for all users in the COM Add-In Manager. See: PRB: Visual Studio .NET Shared Add-in Is Not Displayed in Office COM Add-ins Dialog Box. This is not an error, then.
  • It is a COM add-in for Office and you used Visual Studio 2005 to create it. See: FIX: Add-ins, smart documents, or smart tags that you create by using Microsoft Visual Studio 2005 do not run in Office.
  • The add-in crashed when the host application tried to load it, it prompted you to remove it from the list of available add-ins and you accepted. In this case the add-in is no longer registered for the host application, you must reinstall it (Visual Studio add-ins) or go to the About window, "Disabled Items" button to re-enable it (Office add-ins).

You can use the following monitoring utilities to spy what registry entries or folders the application host uses when it shows the Add-In Manager:

2. The add-in crashes when loaded

This can have several causes:

  • The add-in is registered but the actual path of the Dll does not match the path stated in the InProcServer32 value of the registry entry (Registry-based registration) or in the XML file (Visual Studio 2005 add-ins using XML-based registration). You can use the regedit.exe tool of Windows to discover if this is the problem for COM-addins.
  • The OnConnection, OnStartupComplete or some other method of the add-in called when it is loaded crashes. Ensure that you use exception handlers in each method of the Connect class.
  • You get <Unknown Error> (Error Number 80131522) in a Visual Studio 2005/2008 add-in that uses XML registration (.AddIn file). Likely the namespace and connect class that you have specified in the .AddIn file, <FullClassName> tag does not match the actual namespace and name of the Connect class in the source code.
  • You get "The system cannot find the file specified" (Error Number 80070002): the file pointed by the COM registration or by the <Assembly> tag of the .AddIn file (XML registration) can not be found.

3. The add-in is loaded, but commands, buttons or toolbars are not created

If the add-in is for Visual Studio, see this article:

HOWTO: Adding buttons, commandbars and toolbars to Visual Studio .NET from an add-in

4. The commands are created, but they disappear on the next session

If the add-in is for Visual Studio, see this article:

INFO: Visual Studio .NET Add-In Commands Disappear On Next Session.

5. The commands and buttons are created, but they appear disabled

Ensure that your add-in implements the IDTCommandTarget interface and its QueryStatus method. You must return vsCommandStatus.vsCommandStatusSupported + vsCommandStatus.vsCommandStatusEnabled for your commands. See this article:

HOWTO: Adding buttons, commandbars and toolbars to Visual Studio .NET from an add-in

6. The commands and buttons are created, but clicking on them do nothing

Ensure that your add-in implements the IDTCommandTarget interface and its Exec method. See this article:

HOWTO: Adding buttons, commandbars and toolbars to Visual Studio .NET from an add-in

7. The event handlers of the add-in stop working after a while

If you are using C#, see this article:

PRB: Visual Studio .NET events being disconnected from add-in.

 

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