Windows 7 & IToolBar/ICommand Deployment Issues?

145
22
07-19-2011 01:14 PM
Highlighted
MVP Frequent Contributor
Has anyone run into deployment issues with a custom IToolBar/Command Class and a regular old Setup Project that builds an .msi on a Windows7 Pro (32bit I think) machine????

I have a user that for some reason cannot load the extension/toolbar (it's not really an extension exactly).  But after running the .msi (no error), then choosing "Add From File" to load the .tlb, it still does not show up in the Commands list (so as to place a check to turn the toolbar on).

This same .msi runs and the toolbar shows up just fine on all other installs.

Thanks for any input.
Reply
0 Kudos
22 Replies
Highlighted
MVP Frequent Contributor
Bumping TTT hoping for some feedback this a.m.!

Thanks
Reply
0 Kudos
Highlighted
Regular Contributor III
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.
Reply
0 Kudos
Highlighted
MVP Frequent Contributor
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.


Neil, thanks for the feedback...

Quite possibly that would be the issue because the InstallerClass (which contains the registration process code) doesn't seem to work.  True, the person installing the .msi will log in as Admin then run the .msi --- but unsure if that same person is doing the "Add From File" (not likely as per your comments).

You are right, the InstallerClass should be doing the registering!  Just not sure if the code I have is working as expected.  Here is the current code I am using in the InstallerClass to attempt to register the application on install/running the .msi:


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
Reply
0 Kudos
Highlighted
Regular Contributor III
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
Reply
0 Kudos
Highlighted
MVP Frequent Contributor
That is code to register an addin.  The code for registering COM components is different.


Well hellsbells....

Thanks a bunch!  I'll re-work the Installer class with the suggested code you provided.
Reply
0 Kudos
Highlighted
MVP Frequent Contributor
Neil,

Thanks again for the code. 

Problem --- after adding the corrected code below, the client reports that the toolbar/extension did not show up in the list (by right-clicking the menu area) after running the .msi package (logged in as admin). They attempted to load the .tlb with "Add From File" again, which resulted in the same behavior --- it added the objects, but do not show up in the list to be able to "put a check" into the box to turn on the toolbar.

Additonally, the .msi ran without any issues/hiccups and the installation folder is good!  So, there are no problems with the install.

Any help is appreciated.




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
Reply
0 Kudos
Highlighted
Regular Contributor III
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.  We use VS2010 so we aren't able to use the ESRI addins that come with the 9.3.1 SDK.  We have to copy the component registration code from existing classes and I've accidentally copied it from a command class before instead of a toolbar class.
Reply
0 Kudos
Highlighted
MVP Frequent Contributor
The class that implements IToolbarDef needs to have the component category registration code included in its code module. 


Do you mean to include the Sub Install/Uninstall in the IToolbarDef class?  In other words, just copy over those 2 subs into the IToolbarDef class?  How do they get initiated from within that class (Sub New)?  Just a little confused on this.

Make sure that code is registering with the MxCommandBars category.


Just running the Categories.exe would show the list, right?  Or is this no longer available with ArcGIS 10 install?
Reply
0 Kudos
Highlighted
Regular Contributor III
No, the component category registration code is the code that actually registers the class with the component categories.  ESRI has a VS addin that will generate this code for you if you have the SDK installed and are using a supported version of VS.  Since we develop for 9.3.1 using VS2010 (which is unsupported at 9.3.1) we don't use that addin and instead copy the code from existing classes that were created back when we could use that addin.  It is important to make sure this code is registering the class in the correct category.

Yes, you can use categories.exe to see what classes have been registered.  If your toolbar class is showing up under the Mx CommandBars category, then it is properly registered.  If it is showing up under Mx Commands (or another category) then it is registered in the wrong category.  If you can't find it at all, then it's not registered.
Reply
0 Kudos