Community
Showing results for 
Search instead for 
Do you mean 
Reply

Connected menus not available in Custom Menu sample

New Member
Posts: 4
Country: USA

Connected menus not available in Custom Menu sample

When running the sample code for creating a custom menu item, the connected menus are not available and I get the ubiquitous error message: "Object reference not set to an instance of an object". The code assumes that connected menus are available. Has anyone else run into this problem?

 

 

New Member
Posts: 4
Country: USA

Re: Connected menus not available in Custom Menu sample

Should have mentioned this is with ACT! 2011 and it happens in the RemoveMenuItem() function

Act.UI.Core.CommandBarControl RemoveMenu = this.application.Explorer.CommandBarCollection[CONNECTED_MENUBAR].Control Collection[urn];
Employee
Posts: 1,163
Country: USA

Re: Connected menus not available in Custom Menu sample

Are the menu items being added but it throws the error when your shutting down as it's trying to remove the menu item?

 

If so double check the URN string being used, it may be trying to remove a menu that doesn't exist.

Matthew Wood
Act! SDK Support
Community Moderator
New Member
Posts: 4
Country: USA

Re: Connected menus not available in Custom Menu sample

No this happens at initialization. In the MenuItemExists() function, the CommandBarCollection[CONNECTED_MENUBAR] is being accessed. It is accessed again after the check for menu existence (see code below).The debugger shows only CommandBarCollection[DISCONNECTED_MENUBAR] and CommandBarCollection[DISCONNECTED_TOOLBAR] as being valid. Beside the obvious error of not checking for its existence, should the CommandBarCollection[CONNECTED_MENUBAR] exist after successful logon?

 

 

       private void AddMenuItem(string urn, string text, Act.UI.CommandHandler Handler)
        {
            try
            {
                if (MenuItemExists(urn) == true)
                {
                    RemoveMenuItem(urn);
                }
                Act.UI.Core.CommandBarControl parentMenu = this.application.Explorer.CommandBarCollection[CONNECTED_MENUBAR].ControlCollection[GetParentControlURN(urn)];
                Act.UI.Core.CommandBarButton newMenu = new Act.UI.Core.CommandBarButton(text, text, null, urn, null, null);
                newMenu.DisplayStyle = Act.UI.Core.CommandBarControl.ItemDisplayStyle.TextOnly;
                this.application.RegisterCommand(urn, new Act.UI.CommandHandler(Handler), Act.UI.RegisterType.Shell);
                parentMenu.AddSubItem(newMenu);
            }
            catch { }
        }

 

 

Copper Contributor
Posts: 32
Country: United_Kingdom

Re: Connected menus not available in Custom Menu sample

Bumping this, because I'm having the same issue. Any suggestions? It's kind of weird having sample code that doesn't work

Employee
Posts: 1,163
Country: USA

Re: Connected menus not available in Custom Menu sample

When you debug through this, where is the error being thrown? I use the code from this sample in my bug testing plugin and it works for me. Are you also using 2011 like the original poster?

Matthew Wood
Act! SDK Support
Community Moderator
Copper Contributor
Posts: 32
Country: United_Kingdom

Re: Connected menus not available in Custom Menu sample

thanks for the reply, I think I found a way to do what i needed without this. Cheers