views:

324

answers:

3

I have a menu item in the Tools menu, but it needs to go in the file->new menu, however even changing "Tools" to "File" in the pre-generated visual studio code does not give the expected result!!!?

+1  A: 

You need to change the eventlistner code as well. Check the auto generated code segment at the top part of the code.

Chathuranga Chandrasekara
+1  A: 

The following code (not bulletproof'd!) works fine for me in Addin OnConnection method:

_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
if (connectMode == ext_ConnectMode.ext_cm_UISetup)
{
    object[] contextGUIDS = new object[] { };
    Commands2 commands = (Commands2)_applicationObject.Commands;

    CommandBars commandBars = (CommandBars)_applicationObject.CommandBars;
    CommandBar menuBarCommandBar = commandBars["MenuBar"];

    CommandBarPopup filePopup = menuBarCommandBar.Controls["File"] as CommandBarPopup;
    CommandBarPopup newPopup = filePopup.CommandBar.Controls["New"] as CommandBarPopup;

    Command command = commands.AddNamedCommand2(_addInInstance, "MyAddin1", "MyAddin1", 
        "Executes the command for MyAddin1", true, 59, ref contextGUIDS, 
        (int)(vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled),
        (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);

    if (command == null || newPopup == null)
    {
        command.AddControl(newPopup.CommandBar, 1);
    }
}
Dustin Campbell
The code 'looks' like it should work but putting that code in my project does nothing. I still have my command int he tools menu and I can even go through the breakpoints I set and nothing has changed from appearance
Tom J Nowell
Does this code work if you create a new VS add-in?
Dustin Campbell
+1  A: 

Have you tried running devenv.exe /resetaddin Your.AddIn.Name at the command line (e.g. devenv.exe /resetaddin MyAddin1.Connect)?

Dustin Campbell