views:

13

answers:

0

Hi,

I know there are already some threads about this, but I just won't work for me.

What I want: I need a new entry in a context menu of the Visual Studio Source Control Explorer. For 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 is not working: I don't get any exceptions, the menu just won't show up, no matter where I add it.

Some code snippets:

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", // context menu Name
                         "ClearQuery", // menu reference name
                         "Clear", // display name
                         47, // command icon
                         1);    // command placement, 1= first item on top
                }
}

I am using "Team Project" menu name for testing. VSIPLogging tells me, that this is the name of the menu if I make a right click on our TFS Team Project. I also tried other menus without success.

Here are the AddCommandToContextMenu functions:

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;
                    //create the command
                    Command newCommand = commands.AddNamedCommand2(_addInInstance, commandName, commandText, commandText, true, iconId);
                    // add it to parent menu
                    newCommand.AddControl(parent, position);
    }

The commandbar "parent" gives me quite some exceptions, if I take a closer look at it:

accChildCount = 'parent.accChildCount' threw an exception of type 'Microsoft.VisualStudio.PlatformUI.Automation.DeprecatedException'

The same for every other "acc" value.

Now I really don't know what I did wrong or what else I could try to make this work. All I want to do is to have a context menu entry in the source control explorer, which should call the power tools command line exe to call the "undo unchanged" function of it.