PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, November 8, 2022

[FIXED] Why does my extension's menu item not appear?

 November 08, 2022     menu, visual-studio, visual-studio-2017, visual-studio-extensions     No comments   

Issue

I am building my first VS extension, to allow users to encrypt/decrypt the mailSettings/smtp section of web.config.

I wish to add a menu item that has 2 sub-items to the main VS Tools menu:

Config Encryptor
  Encrypt Mail Settings
  Decrypt Mail Settings

The relevant (I hope) parts of the .vsct file are as follows:

<Menus>
  <Menu guid="guidEncryptConfigCommandPackageCmdSet" id="ConfigEncryptorMenu" priority="0x0100" type="Menu">
    <Parent guid="guidEncryptConfigCommandPackageCmdSet" id="ConfigEncryptorMenuGroup" />
    <Strings>
      <MenuText>Config Encryptor</MenuText>
      <ButtonText>Config Encryptor</ButtonText>
      <CommandName>Config Encryptor</CommandName>
    </Strings>
  </Menu>
</Menus>

<Groups>      
  <Group guid="guidEncryptConfigCommandPackageCmdSet" id="ConfigEncryptorMenu" priority="0x0200">
    <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS" />
  </Group>
  <Group guid="guidEncryptConfigCommandPackageCmdSet" id="ConfigEncryptorMenuGroup" priority="0x0100">
    <Parent guid="guidEncryptConfigCommandPackageCmdSet" id="ConfigEncryptorMenu" />
  </Group>
</Groups>

<Buttons>
  <Button guid="guidEncryptConfigCommandPackageCmdSet" id="cmdidEncryptConfigCommand" priority="0x0100" type="Button">
    <Parent guid="guidEncryptConfigCommandPackageCmdSet" id="ConfigEncryptorMenuGroup" />
    <Strings>
      <ButtonText>Encrypt Mail Settings</ButtonText>
    </Strings>
  </Button>
  <Button guid="guidEncryptConfigCommandPackageCmdSet" id="cmdidDecryptConfigCommand" priority="0x0100" type="Button">
    <Parent guid="guidEncryptConfigCommandPackageCmdSet" id="ConfigEncryptorMenuGroup" />
    <Strings>
      <ButtonText>Decrypt Mail Settings</ButtonText>
    </Strings>
  </Button>
</Buttons>

<GuidSymbol name="guidEncryptConfigCommandPackageCmdSet" value="{2c763b06-e83f-4c03-8fc6-3a00416b361e}">
  <IDSymbol name="ConfigEncryptorMenu" value="0x1010" />
  <IDSymbol name="ConfigEncryptorMenuGroup" value="0x1020" />
  <IDSymbol name="cmdidEncryptConfigCommand" value="0x0100" />
  <IDSymbol name="cmdidDecryptConfigCommand" value="0x1021"  />
</GuidSymbol>

What am I doing wrong that the menu item doesn't appear when I debug the extension project in a new instance of VS?


Solution

There's possibility it's because you've defined a menu whose ID is ConfigEncryptorMenuwhile you also defined a group whose ID is also ConfigEncryptorMenu, which messed up the structure.

Let's define a new IDSymbol called GroupForSubMenu:

<GuidSymbol name="guidEncryptConfigCommandPackageCmdSet" value="{2c763b06-e83f-4c03-8fc6-3a00416b361e}">
 ......
  <!-- New IDSymbol -->
  <IDSymbol name="GroupForSubMenu" value="0x1050"  />
</GuidSymbol>

Then change the content of first Group to:

  <Group guid="guidEncryptConfigCommandPackageCmdSet" id="GroupForSubMenu" priority="0x0200">
    <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS" />
  </Group>

And change the value of <Parent> in Menu section from:

<Parent guid="guidEncryptConfigCommandPackageCmdSet" id="ConfigEncryptorMenuGroup" /> 

to <Parent guid="guidEncryptConfigCommandPackageCmdSet" id="GroupForSubMenu" />

The MenuText is not necessary and the original parent relationship seems to be something like ConfigEncryptorMenuGroup's parent is ConfigEncryptorMenu while ConfigEncryptorMenu's parent is ConfigEncryptorMenuGroup. Correct the relation ship between the groups and menus, the issue can be solved.



Answered By - LoLance
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing