Adding an MsoControlType.msoControlPopup under the "Tools" menu disappears

I'm trying to create a popup menu under the "Tools" menu item like "Tools"->"Test Menu"->"TestAddin". The popup menu appears, the first time, but when I shutdown VisualStudios it does not persist. This is how I'm creating it:

... get "Tools" command bar
CommandBarControl ctrl = (CommandBarControl)
toolCommandBar.Controls.Add
(MsoControlType.msoControlPopup, Type.Missing,
Type.Missing, Type.Missing, false);
ctrl.Caption = "Test Menu";
CommandBarPopup popup = (CommandBarPopup)ctrl;
CommandBar cBar = popup.CommandBar;

commandBarControl = (CommandBarControl)command.AddControl(cBar, 1);

The "temporary" parameter in the Controls.Add() API doesn't seem to affect the persistence of the popup control. How do I create a menu item that can have submenus, and have it persist between uses of the IDE?

[996 byte] By [Reema] at [2007-12-16]
# 1

There are two methods provided by the Connect class: OnConnection and OnStartupComplete. As far as I can see, you placed your code concerning the CommandBarPopup in the OnConnection method, wich is executed only once when the add-in is installed.

If you place your code in the OnStartupComplete method, your CommandBar will be created each time the IDE is started and therefore it won't disappear. As far as I understand only NamedCommands are persistent. I hope this information helps.

t.voelkel at 2007-9-9 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...

Visual Studio

Site Classified