Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6940175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:43:08+00:00 2026-05-27T12:43:08+00:00

I know there are already some threads about this, but I just won’t work

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:43:09+00:00Added an answer on May 27, 2026 at 12:43 pm

    I am pretty sure the Popups in Visual Studio were of CommnadBarPopup type.
    The other thing I am pretty sure was that you need to make your commands / controls global so a reference is kept on them, otherwise GC will kill them.

    You need to make sure that the command name in the AddCommand doesn’t contain dots, and in the Query / Exec functions it does, e.g.:

    newCommand = commands.AddNamedCommand2(_addInInstance, commandName, commandText, commandText, true, iconId, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,(int)vsCommandStyle.vsCommandStylePictAndText,vsCommandControlType.vsCommandControlTypeButton);
    

    Few things to note here:

    1. newCommand is not a local variable as in your code, it is promoted to a global variable to keep it alive (anyway, this is not your case probably, if this was the problem – you would see it the first time and then it will disappear).
    2. You ommited parameters, the ref ContextGUIDS here is a new object[] that was declared just before the method call to hold the guid for the command, it is not that important, just add it, what is important are the next parameters, the first one tells visual studio if the command is visible and enabled : (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled and the next give some hint on what your command should look like (button in our case).

    This is just a start point, plaese refer to this article:
    HOWTO: Create a context menu using a Visual Studio commandbar popup from an add-in

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there are already some threads about this error, but none of them
I know there is already a question about this but my issue is more
There's already a question on this here. But i want to know if its
I know there are already objects supporting Office 2007 files, but is there any
I know there are already many questions like mine but I found no answer
OK, I know there have already been questions about getting started with TDD ..
I know that there are similar questions which are already answered, but I am
I know there are already a few questions regarding recommendations for C++ unit test
First of all: I do know that there are already many questions and answers
First, I know there are methods off of the generic List<> class already in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.