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)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.