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
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.
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
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.