#Region "COM Registration Function(s)" <ComRegisterFunction(), ComVisibleAttribute(False)> _ Public Shared Sub RegisterFunction(ByVal registerType As Type) ' Required for ArcGIS Component Category Registrar support ArcGISCategoryRegistration(registerType) 'Add any COM registration code after the ArcGISCategoryRegistration() call End Sub <ComUnregisterFunction(), ComVisibleAttribute(False)> _ Public Shared Sub UnregisterFunction(ByVal registerType As Type) ' Required for ArcGIS Component Category Registrar support ArcGISCategoryUnregistration(registerType) 'Add any COM unregistration code after the ArcGISCategoryUnregistration() call End Sub #Region "ArcGIS Component Category Registrar generated code" ''' <summary> ''' Required method for ArcGIS Component Category registration - ''' Do not modify the contents of this method with the code editor. ''' </summary> Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type) Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID) MxCommandBars.Register(regKey) End Sub ''' <summary> ''' Required method for ArcGIS Component Category unregistration - ''' Do not modify the contents of this method with the code editor. ''' </summary> Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type) Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID) MxCommandBars.Unregister(regKey) End Sub #End Region #End Region
I see that I incorrectly told you that your original installer class code was for registering an addin. That's not true, that is the code you need for your installer to kick off the component category registration for ArcGIS 10. The code I posted in that reply is for ArcGIS 9.3.1 and earlier. So, if you're deploying for 10 your original installer class code should work now that you corrected the registration code in your toolbar class. If you're deploying for 9.3.1 or earlier then I'm not sure what the problem might be. I think someone mentioned that the installer needs elevated permissions in order to run correctly. You can do this by right-clicking the setup.exe and choosing Run as Admin. I'm not at my work computer right now so I can't look at our installers to see what else we may be doing.
The component category registration code in your toolbar class is registering the toolbar in MxCommands. It should be registering it in MxCommandBars.
#Region "ArcGIS Component Category Registrar generated code" ''' <summary> ''' Required method for ArcGIS Component Category registration - ''' Do not modify the contents of this method with the code editor. ''' </summary> Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type) Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID) MxCommandBars.Register(regKey) End Sub ''' <summary> ''' Required method for ArcGIS Component Category unregistration - ''' Do not modify the contents of this method with the code editor. ''' </summary> Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type) Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID) MxCommandBars.Unregister(regKey) End Sub #End Region
<ComClass(FireToolBarDef.ClassId, FireToolBarDef.InterfaceId, FireToolBarDef.EventsId)> _ Public Class FireToolBarDef Implements IToolBarDef #Region "ArcGIS Component Category Registrar generated code" ''' <summary> ''' Required method for ArcGIS Component Category registration - ''' Do not modify the contents of this method with the code editor. ''' </summary> Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type) Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID) MxCommands.Register(regKey) End Sub ''' <summary> ''' Required method for ArcGIS Component Category unregistration - ''' Do not modify the contents of this method with the code editor. ''' </summary> Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type) Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID) MxCommands.Unregister(regKey) End Sub #End Region #End Region #Region "COM GUIDs" ' These GUIDs provide the COM identity for this class ' and its COM interfaces. If you change them, existing ' clients will no longer be able to access the class. Public Const ClassId As String = "3a781dce-3d88-40be-9351-e0f5d7cdfabf" Public Const InterfaceId As String = "44fdf1a2-255e-4e36-8c09-e59c2d67182a" Public Const EventsId As String = "a0b77313-5f65-4a41-9d90-779112341e6c" #End Region ' A creatable COM class must have a Public Sub New() ' with no parameters, otherwise, the class will not be ' registered in the COM registry and cannot be created ' via CreateObject. Public Sub New() MyBase.New() End Sub Public ReadOnly Property Caption() As String Implements ESRI.ArcGIS.SystemUI.IToolBarDef.Caption Get Return "Fire_V3.1" End Get End Property Public Sub GetItemInfo(ByVal pos As Integer, ByVal itemDef As ESRI.ArcGIS.SystemUI.IItemDef) Implements ESRI.ArcGIS.SystemUI.IToolBarDef.GetItemInfo Select Case pos Case 0 itemDef.ID = "Fire_v3_1.clsFire" itemDef.Group = True End Select End Sub Public ReadOnly Property ItemCount() As Integer Implements ESRI.ArcGIS.SystemUI.IToolBarDef.ItemCount Get Return 1 End Get End Property Public ReadOnly Property Name() As String Implements ESRI.ArcGIS.SystemUI.IToolBarDef.Name Get Return "Fire_V3.1" End Get End Property End Class
<ComClass(clsFire.ClassId, clsFire.InterfaceId, clsFire.EventsId), ProgId("Fire_v3_1.clsFire")> _ Public Class clsFire 'ProgId("Fire_v2_0.clsFire_v2")> Implements ESRI.ArcGIS.SystemUI.ICommand Implements ESRI.ArcGIS.SystemUI.IToolControl Private m_pApp As IApplication Private pDoc As IMxDocument Private pMap As IMap Private pLayer As IFeatureLayer Private sLayerName As String Private m_completionNotify As ICompletionNotify Private m_FireUC As FireUC = New FireUC #Region "COM GUIDs" ' These GUIDs provide the COM identity for this class ' and its COM interfaces. If you change them, existing ' clients will no longer be able to access the class. Public Const ClassId As String = "01cf11bf-9fac-45e6-892a-4fc0fe020753" Public Const InterfaceId As String = "732b6107-f31b-4078-b257-a718f725500e" Public Const EventsId As String = "03223c0d-bf75-4b00-9cb8-966ed1428b18" #End Region #Region "ArcGIS Component Category Registrar generated code" ''' <summary> ''' Required method for ArcGIS Component Category registration - ''' Do not modify the contents of this method with the code editor. ''' </summary> Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type) Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID) MxCommands.Register(regKey) End Sub ''' <summary> ''' Required method for ArcGIS Component Category unregistration - ''' Do not modify the contents of this method with the code editor. ''' </summary> Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type) Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID) MxCommands.Unregister(regKey) End Sub #End Region ' A creatable COM class must have a Public Sub New() ' with no parameters, otherwise, the class will not be ' registered in the COM registry and cannot be created ' via CreateObject. Public Sub New() MyBase.New() End Sub Public ReadOnly Property Bitmap() As Integer Implements ESRI.ArcGIS.SystemUI.ICommand.Bitmap Get End Get End Property Public ReadOnly Property Caption() As String Implements ESRI.ArcGIS.SystemUI.ICommand.Caption Get Return "Fire_V3.1" End Get End Property Public ReadOnly Property Category() As String Implements ESRI.ArcGIS.SystemUI.ICommand.Category Get Return "Fire_V3.1" End Get End Property Public ReadOnly Property Checked() As Boolean Implements ESRI.ArcGIS.SystemUI.ICommand.Checked Get Return False End Get End Property Public ReadOnly Property Enabled() As Boolean Implements ESRI.ArcGIS.SystemUI.ICommand.Enabled Get Return True End Get End Property Public ReadOnly Property HelpContextID() As Integer Implements ESRI.ArcGIS.SystemUI.ICommand.HelpContextID Get End Get End Property Public ReadOnly Property HelpFile() As String Implements ESRI.ArcGIS.SystemUI.ICommand.HelpFile Get Return "" End Get End Property Public ReadOnly Property Message() As String Implements ESRI.ArcGIS.SystemUI.ICommand.Message Get Return "" End Get End Property Public ReadOnly Property Name() As String Implements ESRI.ArcGIS.SystemUI.ICommand.Name Get Return "Fire_V3.1" '"clsFire" End Get End Property Public Sub OnCreate(ByVal hook As Object) Implements ESRI.ArcGIS.SystemUI.ICommand.OnCreate Try System.Windows.Forms.Application.EnableVisualStyles() If Not (hook Is Nothing) Then If TypeOf (hook) Is IMxApplication Then m_pApp = CType(hook, IApplication) m_FireUC.m_pApp = m_pApp End If End If If Nothing Is m_FireUC Then m_FireUC = New FireUC m_FireUC.CreateControl() End If Catch ex As Exception MsgBox(ex.ToString) Exit Sub End Try End Sub Public Sub OnClick() Implements ESRI.ArcGIS.SystemUI.ICommand.OnClick End Sub Public ReadOnly Property Tooltip() As String Implements ESRI.ArcGIS.SystemUI.ICommand.Tooltip Get Return "clsFire" End Get End Property Public ReadOnly Property hWnd() As Integer Implements ESRI.ArcGIS.SystemUI.IToolControl.hWnd Get If Nothing Is m_FireUC Then m_FireUC = New FireUC m_FireUC.CreateControl() End If hWnd = m_FireUC.Handle.ToInt32 End Get End Property Public Function OnDrop(ByVal barType As ESRI.ArcGIS.SystemUI.esriCmdBarType) As Boolean Implements ESRI.ArcGIS.SystemUI.IToolControl.OnDrop OnDrop = True End Function Public Sub OnFocus(ByVal complete As ESRI.ArcGIS.SystemUI.ICompletionNotify) Implements ESRI.ArcGIS.SystemUI.IToolControl.OnFocus m_FireUC.CompletionNotify = complete End Sub End Class
James,I had to do a similar thing for an editor component this morning and found it didn't work either so i spent the last couple of hours working out whats going on. Fortunately its an 'easy' fix.Presumably you're using the procedure from: How to deploy a custom component using a setup project.If your deploying to a windows 7 machine then User Account Control (UAC) is probably turned on by default. This means that ESRIRegAsm.exe needs to run as administrator to actually do anything useful. Being part of the administrators group in windows 7 isnt good enough, the exe will need to run with elevated privileges (I usually set the program compatibility to run as administrator when manually working with dll's).To do this in your setup, add the following lines in the installer class (in the InvokeESRIRegAsm project) to read: ProcessInfo.UseShellExecute = false; ProcessInfo.Verb = "runas"; //aka run as administratorin the ExecuteCommand procedure.You'll also have to change the custom action scripts in the Setup project itself.Try entering /arg1="[TARGETDIR]\???.dll" for the install and uninstall custom action scripts. (replace ??? with your dll name of course).This works for me anyway. I'll have a chat to the SDK team about the doc...
Hello James,If your development environment is 32 bit and are deploying on 64 bit machine then build your application with the compiler option set to x86 in visual studio solution.ESRI components have to be compiled as x86, even though they are being deployed on 64 bit machine.Sumit
No, the component category registration code is the code that actually registers the class with the component categories.
The class that implements IToolbarDef needs to have the component category registration code included in its code module.
Make sure that code is registering with the MxCommandBars category.
That is code to register an addin. The code for registering COM components is different.Imports System.ComponentModel Imports System.Configuration.Install Imports System.Runtime.InteropServices Imports System.Windows.Forms Imports System.IO Imports System.Security.AccessControl Public Class Installer1 Public Sub New() MyBase.New() 'This call is required by the Component Designer. InitializeComponent() 'Add initialization code after the call to InitializeComponent End Sub Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary) Dim pRegSvr As New RegistrationServices Try MyBase.Install(stateSaver) If Not pRegSvr.RegisterAssembly(MyBase.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase) Then Throw New InstallException("COM registration failed. Some or all of the application classes are not properly registered in the ESRI component categories.") End If Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message, "Install Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary) Dim pRegSvr As New RegistrationServices Try MyBase.Uninstall(savedState) If Not pRegSvr.UnregisterAssembly(MyBase.GetType().Assembly) Then Throw New InstallException("COM unregistration failed. Some or all of the application classes were not properly removed from the ESRI component categories.") End If Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message, "Uninstall Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub End Class
Imports System.ComponentModel Imports System.Configuration.Install Imports System.Runtime.InteropServices Imports System.Windows.Forms Imports System.IO Imports System.Security.AccessControl Public Class Installer1 Public Sub New() MyBase.New() 'This call is required by the Component Designer. InitializeComponent() 'Add initialization code after the call to InitializeComponent End Sub Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary) Dim pRegSvr As New RegistrationServices Try MyBase.Install(stateSaver) If Not pRegSvr.RegisterAssembly(MyBase.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase) Then Throw New InstallException("COM registration failed. Some or all of the application classes are not properly registered in the ESRI component categories.") End If Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message, "Install Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary) Dim pRegSvr As New RegistrationServices Try MyBase.Uninstall(savedState) If Not pRegSvr.UnregisterAssembly(MyBase.GetType().Assembly) Then Throw New InstallException("COM unregistration failed. Some or all of the application classes were not properly removed from the ESRI component categories.") End If Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message, "Uninstall Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub End Class
That is code to register an addin. The code for registering COM components is different.
Does the user have admin privileges on the machine? If not, Add from File won't work for them because it requires entries to be created in the system registry. Also, you can have your installer do this during install (it will also need admin rights). There's really no need to require the user to do anything other than run your installer then open ArcMap and turn on your toolbar.
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary) MyBase.Install(stateSaver) 'Register the custom component. '----------------------------- 'The default location of the ESRIRegAsm utility. 'Note how the whole string is embedded in quotes because of the spaces in the path. Dim cmd1 As String = """" + Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles) + "\ArcGIS\bin\ESRIRegAsm.exe" + """" Dim part1 As String = Me.Context.Parameters.Item("arg1") 'Add the appropriate command line switches when invoking the ESRIRegAsm utility. 'In this case: /p:Desktop = means the ArcGIS Desktop product, /s = means a silent install. Dim part2 As String = " /p:Desktop /s" 'It is important to embed the part1 in quotes in case there are any spaces in the path. Dim cmd2 As String = """" + part1 + """" + part2 'Call the routing that will execute the ESRIRegAsm utility. Dim exitCode As Integer = ExecuteCommand(cmd1, cmd2, 10000) End Sub Public Shared Function ExecuteCommand(ByVal Command1 As String, ByVal Command2 As String, ByVal Timeout As Integer) As Integer 'Set up a ProcessStartInfo using your path to the executable (Command1) and the command line arguments (Command2). Dim ProcessInfo As ProcessStartInfo = New ProcessStartInfo(Command1, Command2) ProcessInfo.CreateNoWindow = True ProcessInfo.UseShellExecute = False 'Invoke the process. Dim Process As Process = Process.Start(ProcessInfo) Process.WaitForExit(Timeout) 'Finish. Dim ExitCode As Integer = Process.ExitCode Process.Close() Return ExitCode End Function
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.