Windows 7 & IToolBar/ICommand Deployment Issues?

982
22
07-19-2011 01:14 PM
JamesCrandall
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.
0 Kudos
22 Replies
JamesCrandall
MVP Frequent Contributor
No, the component category registration code is the code that actually registers the class with the component categories.



I must have an issue with my ICommand class (probably with the Category/Name properties, really don't know at this point).  In any event....

I am getting a little desperate to get this installed on the client.  Can anyone explain why I can manually register the .tlb (via Customize-->Add From File) without any problem EXCEPT on a Windows7 32-bit computer (using admin priv's account at login)?

Edit: the ArcObjects SDK does not appear to be installed correctly as I cannot see any of the ArcGIS project templates or have the ArcGIS Component Category Registrar.
0 Kudos
SumitSharma
New Contributor III
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
0 Kudos
JamesCrandall
MVP Frequent Contributor
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


Sumit,

Thank you for your reply/input.  The problem is that the client computer is 32-bit running W7 (I am told) and I am unsure what the dev machine is right now.  What if the dev computer is 64-bit?  What option should it be set to then?

Thanks again!

james
0 Kudos
by Anonymous User
Not applicable
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 administrator
in 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...
0 Kudos
JamesCrandall
MVP Frequent Contributor
Thanks for your detailed reply, Sean.  I'll take another stab creating a new setup project (yes that's the link I was following originally) and try the settings you specify.  Will keep you posted.

Again --- thanks for your effort and help!


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 administrator
in 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...
0 Kudos
JamesCrandall
MVP Frequent Contributor
I am still not having any success with this.  So, I went back and tried to get this to work on a WinXP platform and I still cannot get the COM component to register (however, I can load the ICommand/IToolbar Class by way of Customize-->Add From File-->.tlb on the XP workstation).

So, here is everything I have.  If there is anything blaringly incorrect, please let me know.

clsFire.vb is the ICommand and IToolbar class.  The app utilizesa UserControl (you'll see that I pass the app ref to it in the OnCreate):

<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


Then, I have followed the steps exactly as outlined here:

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_deploy_a_custom_...

The InvokeESRIRegAsm project and Installer class are EXACTLY as described in the walkthru. 

The Setup Project itself has been created EXACTLY as outlined in the walkthru.  Additionally, I have tried a multitude of various settings for the Install/Uninstall of the CustomActionData settings -- all of which produce the same behavior:

The install runs without error, the directories are created and the referenced .dll's all copied over.  But the registration does not work.  I am not sure if there is something incorrect in the ICommand Name/Category/Caption properties of clsFire (which is why I have posted), but again the Toolbar does not show up in the Toolbars or Commands listings. 

I CAN register the files manually by way of Customize-->Add from file, but this is only on XP machines.  This does not work on W7 machines, which is why I believe there is something else going wrong in my Setup or InvokeESRIRegAsm.

Any more help is greatly appreciated.
0 Kudos
JamesCrandall
MVP Frequent Contributor
Couldn't add the IToobarDef class code:

<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
0 Kudos
NeilClemmons
Regular Contributor III
The component category registration code in your toolbar class is registering the toolbar in MxCommands.  It should be registering it in MxCommandBars.
0 Kudos
JamesCrandall
MVP Frequent Contributor
The component category registration code in your toolbar class is registering the toolbar in MxCommands.  It should be registering it in MxCommandBars.


I had really hoped it was (and still hope it is) something like this.  Unfortunately, it still did not register either the Toolbar or Command.  Here are the changes I made to the ToolbarDef class:

#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
0 Kudos
NeilClemmons
Regular Contributor III
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.
0 Kudos