locked
Menus are not shown in Custom Package created with MPF RRS feed

  • Question

  • Hi Guys,

    I am working on my custom project type and having problems introducing new context menu item on a project node (or on any node to that matter).

    I am using MPF and VS2012, my custom project loads just fine in VS Experimental, the project is created according to its template, but I see no menu buttons.

    Hete is how I declare it in my *.vsct file:

    <?xml version="1.0" encoding="utf-8"?>
    <CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    
      <Extern href="stdidcmd.h" />
      <Extern href="vsshlids.h" />
    
      <Commands package="guidProjectPkg">
        
        <Groups>
          <Group guid="guidProjectCmdSet" id="ProjectNodeGroup" priority="0x0600">
            <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE" />
          </Group>
        </Groups>
    
        <Buttons>
          <Button guid="guidProjectCmdSet" id="cmdIdDeploy" priority="0x0100" type="Button">
            <Parent guid="guidProjectCmdSet" id="ProjectNodeGroup" />
            <Strings>
              <ButtonText>Deploy</ButtonText>
            </Strings>
          </Button>
        </Buttons>
      </Commands>
      
      <Symbols>
        <GuidSymbol name="guidProjectPkg" value="{b14fa699-88b9-4077-86a1-a3011f44f87d}" />
        <GuidSymbol name="guidProjectCmdSet" value="{7b8e0194-5dbd-48a4-995d-9e4b7b5a4580}">    
          <IDSymbol name="ProjectNodeGroup" value="0x1020"/>
          <IDSymbol name="cmdIdDeploy" value="0x0100"/>
        </GuidSymbol>    
      </Symbols>
    </CommandTable>

    The Guids are correct, I spent hours checking and double-checking them.

    Here is how I wire up the command in my package class:

    protected override void Initialize()
    {
        Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
        base.Initialize();
        this.RegisterProjectFactory(new MyProjectFactory(this));
    
        var menuService = this.GetService(typeof(IMenuCommandService)) as IMenuCommandService;
        RegisterCommands(menuService);
    }
    
    private void RegisterCommands(IMenuCommandService menuService)
    {
        // Create the command for the menu item.
        var menuItem = new MenuCommand(MenuItemCallback, ProjectMenus.Deploy);
        menuService.AddCommand(menuItem);
    }
    
    private void MenuItemCallback(object sender, EventArgs e)
    {
        // Nothing interesting here
    }
    

    And here is the command itself:

        public static class ProjectMenus
        {
            internal static readonly CommandID Deploy = new CommandID(GuidList.ProjectCmdSet, 0x0100);
        }

    I went to the registry and checked the "HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0Exp_Config\Menus" key, my package Guid and ", 1000, 1" is there.

    I downloaded VSCTPowerToy and menus/groups seem to be correct.

    I tried to override QueryStatusCommand and QueryStatusOnNode just to set the breakpoint and see if my command is even requested by Visual Studio - doesn't seem so, my breakpoints never hit.

    What else do I check?

    Help please!! :)


    MCP, MCAD

    Monday, January 28, 2013 12:50 PM

Answers

  • That is incorrect, he is trying to add a button to an existing menu, he doesn't need to create a menu to do that.

    When you say you have used VSCTPowerToy I assume you mean you looked at the assembly and the command was there? I say this because VSCTPowerToy does not work on the CTM (merged command table) or on assemblies that have images in them (the image storage format was changed in 2012 and VSCTPowerToy has not been updated yet).

    Generally when something is in an assembly and not in the final CTM it means it was eliminated at merge time as 'unused'. You can try adding a UsedCommands section and a UsedCommand entry for your command. Ignore MSDN, its explanation of what the USedCommands section is is wrong, I will file a doc bug on that.

    Ryan

    • Marked as answer by Ego Jiang Monday, February 18, 2013 7:39 AM
    Monday, January 28, 2013 3:43 PM

All replies

  • Hi,

    Welcome to the joy of VSCT :-)

    First problem is you don't have any Menu Xml Element in your VSCT. Groups are not Menus.

    I suggest you take a deep look at this article (the whole "LearnVSXNow" series is in fact a must-read for VSX starters): http://dotneteers.net/blogs/divedeeper/archive/2008/03/02/LearnVSXNowPart14.aspx

    especially the "A few samples for creating menus" chapter.


    Simon Mourier


    Monday, January 28, 2013 2:22 PM
  • That is incorrect, he is trying to add a button to an existing menu, he doesn't need to create a menu to do that.

    When you say you have used VSCTPowerToy I assume you mean you looked at the assembly and the command was there? I say this because VSCTPowerToy does not work on the CTM (merged command table) or on assemblies that have images in them (the image storage format was changed in 2012 and VSCTPowerToy has not been updated yet).

    Generally when something is in an assembly and not in the final CTM it means it was eliminated at merge time as 'unused'. You can try adding a UsedCommands section and a UsedCommand entry for your command. Ignore MSDN, its explanation of what the USedCommands section is is wrong, I will file a doc bug on that.

    Ryan

    • Marked as answer by Ego Jiang Monday, February 18, 2013 7:39 AM
    Monday, January 28, 2013 3:43 PM