This document is archived and information here might be outdated.  Recommended version.

How to ensure that COM component category and COM interop are used in custom components (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Extending ArcObjects > How to ensure that COM component category and COM interop are used in custom components

How to ensure that COM component category and COM interop are used in custom components

Traditional .NET developers might not be familiar with some of the unique Component Object Model (COM) characteristics that need to be understood in ArcObjects development of custom components. This topic serves as a primer for ArcObjects developers who want to ensure that their Visual Studio projects have COM component category registration information and that COM interop is selected. This information is necessary when performing debugging and deployments.

In this topic

About COM component category and COM interop

Before proceeding, review the following assumptions:
  • An ArcGIS Desktop custom component (called CustomComponent) was created based on implementing COM interfaces or Esri base classes in Visual Studio.
  • CustomComponent has a Developer Samples Category property.
  • CustomComponent has a Caption ArcMapClassLibrary_Implements Caption property.  
  • CustomComponent was created on a machine called DevelopmentPC.
  • CustomComponent will be deployed on a machine called TargetPC.
  • The CustomComponent in this topic is the type that can be shown on the Customize dialog box in an ArcGIS Desktop application (that is, ArcMap, ArcGlobe, ArcScene, or ArcCatalog) and can be added to or removed from the ArcGIS Desktop graphical user interface (GUI). Typically, these types of CustomComponents are Buttons, Tools, and Toolbars. Examples of CustomComponents that do not show on the Customize dialog box and are not relevant in this topic are Extensions, Dockable Windows, custom table of contents (TOCs), and so on. 

    The following screen shot shows an example of an ArcMap Customize dialog box:

Ensuring information is available and enabled

COM systems use an area of the Windows registry called component categories. Conceptually, a component category is a convenient way to logically group classes that provide a certain type of functionality. Generally, all classes in a particular category support an approved set of interfaces; although, sometimes the classes conform to a semantic description of functionality. Any application can read the contents of a component category at run time in the Windows registry to gather information about which classes support certain functionality without that application needing to know precise class names in advance.
Prior to ArcGIS 10, ArcObjects made extensive use of component categories in the Windows registry to improve the extensibility of ArcGIS. The Windows RegAsm.exe utility was used to extract the component category information from an ArcGIS custom component and enter the component category information into the Windows registry. When the ArcGIS Desktop application ran, it looked in the component categories of the Windows registry to see what extensible customization options were available. 
At ArcGIS 10, it was decided to move away from using the Windows registry to store COM component category information. The replacement consists of a registration utility - ESRIRegAsm.exe - and an Extensible Markup Language (XML) database stored in published per product and version configuration folders, independent of the system registry. Therefore, for ArcGIS 10 and later, the registration of component and category information for a developer's assembly or dynamic-link library (DLL) is achieved using the Esri utility called ESRIRegAsm. For more information, see ESRIRegAsm utility.
The reason to ensure that COM component category registration information (whether stored in the Windows registry or the Esri XML database) is available and that COM interop is selected for the ArcGIS Desktop custom component is so that problems are avoided during debugging and deployment.
An ArcGIS Desktop custom component that has the correct component category registration information and has COM interop selected in the Visual Studio project shows on the Customize dialog box of an ArcGIS Desktop application (ArcMap.exe, ArcCatalog.exe, ArcGlobe.exe, and ArcScene.exe). The CustomComponent shows on the Customize dialog box in ArcMap, which resembles the following screen shot:

Determining the COM component category and ensuring that COM interop is selected

If the Esri integrated development environment (IDE) features of Visual Studio are used to create the CustomComponent, it is easy to determine the component category information and whether COM interop is selected. The Esri Visual Studio IDE features are installed as part of the ArcObjects .NET software development kit (SDK).
Complete the following steps to determine that the COM component category is registered with ArcMap and ensure the project has COM interop selected:
  1. Start Visual Studio on the DevelopmentPC and open the CustomComponent project.
  2. Click Project, then select Add Component Category. See the following screen shot:

  3. When you click Add Component Category on the preceding screen shot, the ArcGIS Component Category Registrar dialog box appears.
    1. Click the Class drop-down list, select the applicable class that has the customization, and look for selected categories under the Categories section. In this example, the customization is in the ArcMapClassLibrary_Implements.ArcGISClass1 class and the ArcMap Command category is selected. Under the Properties section, the Caption property is ESRI Mx Commands.
    2. Check the Register for COM Interop check box.

      See the following screen shot:

Another way to determine that you have the correct COM component category registered, is to review the class code in the project for the ArcGISCategoryRegistration method.
On the following VB.NET screen shot, the (ArcMapClassLibrary_Implements.ArcGISClass1) class the command is registered with is MxCommands.

On the following C# screen shot, the (ArcMapClassLibrary_Implements.ArcGISClass1) class the command is registered with is MxCommands.

  1. Click Project, and select <project name> Properties from the menus to ensure that COM interop functionality is selected in the CustomComponent project's properties. See the following screen shot:

  2. After you select the <project name> Properties from the menus, the property information appears. Ensure that the Register for COM interop check box is checked.
To access the Register for COM interop in a VB.NET project, click the Compile tab. See the following screen shot:

To access the Register for COM interop check box in a C# project, click the Build tab. See the following screen shot:

See Also:

Deploying custom components
How to deploy a custom component using a setup project
Obtaining the Category and Caption property information of a custom component
ESRIRegAsm utility

Development licensing Deployment licensing
ArcGIS Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
Engine Developer Kit Engine