I know that this already has some topics, but I just wonโt work for me.
What I want: I need a new entry in the Visual Studio Source Control Explorer context menu. To do this, I started a new add-in project.
What I used: I used this article as a guide.
http://blogs.msdn.com/b/team_foundation/archive/2010/06/24/extending-work-item-tracking-context-menus.aspx
What does not work: I have no exceptions, the menu simply will not appear, no matter where I add it.
Some snippets of code:
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
if(connectMode == ext_ConnectMode.ext_cm_UISetup)
{
AddCommandToContextMenu(
"Team Project",
"ClearQuery",
"Clear",
47,
1);
}
}
I use the Team Project menu name for testing. VSIPLogging tells me that this is the name of the menu if I right-click on our Team TFS project. I also tried other menus without success.
AddCommandToContextMenu:
private void AddCommandToContextMenu(string menuName, string commandName, string commandText, int iconId, int position)
{
CommandBar contextMenu = ((CommandBars)_applicationObject.CommandBars)[menuName];
AddCommand(contextMenu, commandName, commandText, iconId, position);
}
private void AddCommand(CommandBar parent, string commandName, string commandText, int iconId, int position)
{
Commands2 commands = (Commands2)_applicationObject.Commands;
Command newCommand = commands.AddNamedCommand2(_addInInstance, commandName, commandText, commandText, true, iconId);
newCommand.AddControl(parent, position);
}
"parent" , :
accChildCount = 'parent.accChildCount' "Microsoft.VisualStudio.PlatformUI.Automation.DeprecatedException"
"acc".
, , . , , -, exe, " ".