Select to view content in your preferred language

Component not registering itself :(

2047
1
04-15-2010 02:46 AM
UjjwalNigam
Regular Contributor
Hi All,
I am working on a utility using ArcObjects.
I have created a toolbar using IToolbarDef containing two buttons using ICommand.

The issue is that the the buttons don't attach themselves to the toolbar. In the toolbar code, in method GetItemInfo(), I specify the classname of the COM classes containing the command button code.
'**********
Select Case pos
            Case 0
                itemDef.ID = "81c4a489-678b-49cb-9af5-4d49df6933a6"
                itemDef.Group = True
            Case 1
                itemDef.ID = "2f050a4f-124f-4eff-9b68-4e6faca643d4"
                itemDef.Group = True
End Select
'***********
Now when I build, and check in ArcMap, I do see a Toolbar entry and two command button entries under the relevant category. But when I enable the toolbar in ArcMap, it is an empty toolbar without any buttons. I have to manually drag the buttons onto the toolbar, which obviously I would not want.

What could be the reason? Any help would be appreciated.

PS: I have also tried including  a standard class with Install and Uninstall methods, but nothing works.
'**********
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
        MyBase.Install(stateSaver)
        Dim regsrv As New RegistrationServices
        regsrv.RegisterAssembly(MyBase.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase)
    End Sub

    Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
        MyBase.Uninstall(savedState)
        Dim regsrv As New RegistrationServices
        regsrv.UnregisterAssembly(MyBase.GetType().Assembly)
End Sub

'**********

Thanks in advance!!!
0 Kudos
1 Reply
NeilClemmons
Honored Contributor
When you set the Id property you need to include the curly braces {} as part of the GUID.

itemDef.ID = "{81c4a489-678b-49cb-9af5-4d49df6933a6}"

Another more human readable way to do this is to use the ClassId constant available from your command class.

itemDef.ID = "{" & yourCommandClass.ClassId & "}"
0 Kudos