ESRI Compile and Register
This Visual Basic add-in supports the building of components and the subsequent registration of these components into the appropriate component category. To access the add-in, click ESRI Compile and Register on the Add-Ins menu in Visual Basic. For convenience, the add-in lists the most commonly used ESRI component categories, though the list of categories can be controlled from the Components menu. The add-in’s user interface is shown below.
The Compile and Register add-in enhances VB by adding support for component categories.
Classes list and Component Categories list
The add-in lists all the classes defined within the VB project in the left column and lists all the available component categories in the right column. The developer selects a class in the left column and checks the appropriate component categories in the right. When a project is loaded, the interface updates to reflect the project’s classes, and if these classes are within component categories the categories list also updates. If the class has not been registered in a category all items in the list will be unchecked.
It is not a good idea to have classes that have a ProgID of project1.class1. This will be the result if the default project name and class name are not changed before compilation. Any classes that have a ProgID that is project1.class1 will not automatically be loaded in the form.
Remember, component categories are used by client applications to efficiently find all components of a particular type that are installed on the system. For example, ArcMap uses component categories extensively to efficiently locate installed components on a user’s system. Component categories support the extensibility of COM by allowing the developer of the client application to create and work with classes that belong to a particular category. If at a later date a new class is added to the category, the client application need not be changed to take advantage of the new class; it will automatically pick up the new class the next time the category is read.
Options menu
The Options menu has five items: Display Dialogs, Unregister on Error, Set Binary Compatibility, Support Visual Basic Debugger and ArcGIS Debug Application.
The states of all the items on the Options menu are saved in the registry, and loaded on subsequent uses of the tool. By default, they are all enabled.
Display Dialogs
Check this option to display dialog boxes informing you of the operations that are being
performed; saving the source files, compiling and registering the component,
and so on.
Unregister On Error
This option sets the behavior if an error is encountered during the compilation and registration process.
If checked when an error occurs at any time during the execution of the add-in,
the component is unregistered from the system.
Set Binary Compatibility
Check this item to automatically set the project's component compatibility
to be Binary with the newly compiled DLL.
Support Visual Basic Debugger
This option creates a debug helper EXE (ESRIVBDebugHelper.exe) to solve component category issues when debugging.
Using this executable as the Start Program for the debugger will help you debug your Visual Basic project.
The executable registers the classes to the chosen component categories after the debug session has started,
thus working around one of the main issues with debugging Visual Basic COM projects.
The ArcGIS Debug Application option lets you choose which ArcGIS application you want the debug helper to start.
You can inspect what the debug helper does by opening its Visual Basic project (ESRIVBDebugHelper.vbp)
which is created in a subfolder called 'ESRIVBDebugHelper' alongside your Visual Basic project.
Components menu
The Components menu has two items: Select Component Categories and Reset Component Categories. Select Component Categories displays the dialog shown below. Using this dialog, it is possible to select the Component Categories that the add-in displays in its Component Categories list. To reset the list back to the default settings, use the Reset Component Categories menu command.
The Component Categories dialog allows you to configure the component categories supported by the adding.
Premier Toolbars...
If the current Visual Basic project has a class that is marked to go into one of the command bar categories (ESRI Mx Command Bars, ESRI Gx Command Bars, ESRI Sx Command Bars or ESRI GMx Command Bars) the class can be marked as a premier toolbar.
To flag a toolbar class as a premier toolbar you must display the Premier Toolbar Classes check list by clicking the Premier Toolbars button. This displays the list box shown below. All classes that are in the appropriate component category will be placed in this list. If the classes are already in the registry as premier toolbars, they will be automatically checked. To remove them from the registry, uncheck the class and compile the project. All classes checked will be added to the registry as premier toolbars. When developing the project, you must be aware that after every compile (by the add-in) the toolbar will act like a fresh install when ArcMap or ArcCatalog is next started (that is, even if the toolbar was previously hidden, it will appear).
Premier toolbars are toolbars that are displayed the first time an ArcGIS application (ArcMap, ArcCatalog, ArcScene or ArcGlobe) is started after its installation. Once the user has hidden the toolbar for the first time, it is no longer displayed. This is good way of highlighting the installation of customizations to the user.
The required changes to the registry are made at compile time. An entry is also made in the registry script to ensure that the class is also marked as a Premier toolbar at install time.
Compile
When each class has the appropriate component category selected the project can be built. Clicking the Compile button builds the project. Upon completion of a successful compile, the classes are registered into the required component category. If a class’s component category changes, the class is removed from the old component category. If a class is not marked as a member of any category, it will be removed from any of the supported categories in which it is currently registered. If the developer has displayed the form once or the class already exists within the category, the Compile command can be executed directly by holding down the Ctrl key when selecting the add-in from the menu.
Before compiling the project, all source files within the project are saved. If a module has never been saved, the developer is prompted to save the project via the standard VB interface. This ability to save source files prior to a compile gives functionality that is not present in Visual Basic. Visual Basic only saves source files prior to building executables; it does not save source files when building DLLs.
Since the process of component category registration is tied to the compilation, these classes will only be registered in the categories on the developer’s machine. To help with the installation of components on third-party machines, the compilation process also generates a Registry Script file. The file has the same name as the project with a .reg extension, and is located in the VB Project directory. A sample script is shown below.
REGEDIT4
;This Registry Script enters CoClasses Into their appropriate Component Category
;Use this script during installation of the components
;CoClass:prjDisplay.ZoomIn
;CLSID:{FC7EC05F-6B1B-4A59-B8A2-37CE33738728}
;Component Category:ESRI Mx Commands
[HKEY_LOCAL_MACHINE \SOFTWARE \Classes \CLSID \{FC7EC05F-6B1B-4A59-B8A2-37CE33738728}\Implemented Categories \{B56A7C42-83D4-11D2-A2E9-080009B6F22B}]
;CoClass:prjDisplay.ZoomOut
;CLSID:{2C120434-0248-43DB-AD8E-BD4523A93DF8}
;Component Category:ESRI Mx Commands
[HKEY_LOCAL_MACHINE \SOFTWARE \Classes \CLSID \{2C120434-0248-43DB-AD8E-BD4523A93DF8}\Implemented Categories \{B56A7C42-83D4-11D2-A2E9-080009B6F22B}]
DLL Registration
The add-in also registers the newly created DLL on your machine. In the case of DLLs with very long pathnames (more than 128 characters) Visual Basic may not register the DLL correctly. For more details refer to ESRI Technical Article 19941 (http://support.esri.com/search/KbDocument.asp?dbid=19941).
Windows installers and .reg files
Some Windows installers, including Wise for Windows Installer through to version 3.51, may not correctly process the .reg files created by the Compile and Register add-in. There may be no reported error. This situation can be solved by removing the comments from the .reg file, and placing a blank line between each entry in the .reg file.