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

  • Home
  • SEARCH
  • 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 4531806
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T13:56:58+00:00 2026-05-21T13:56:58+00:00

I want to be able to create a Visual Studio add-in with a number

  • 0

I want to be able to create a Visual Studio add-in with a number of commands. In the addin’s OnConnection method the wizard generates this boilerplate:

Command command = commands.AddNamedCommand2(_addInInstance, "MyAddin", "MyAddin", 
  "Executes the command for MyAddin", true, 59, ref contextGUIDS, ... )

This creates a single command for MyAddin on the Tools menu, but any attempt I make to create further commands are ignored:

    Command command = commands.AddNamedCommand2(_addInInstance, "MyAddin command2", "MyAddin command2", 
  "Executes the command for MyAddin command 2", true, 59, ref contextGUIDS, ... )

Is this a restriction of Addins themselves, that they can only correspond to a single menu item? Or does it have to be done in a different way? Should I be writing a VSPackage instead?

  • 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-21T13:56:59+00:00Added an answer on May 21, 2026 at 1:56 pm

    I found that you aren’t in fact limited to creating a single command in an AddIn. The problem turned out to be that the command names can’t have spaces in them as I had in the above example. In the Connect method of my addin I’ve now got a loop that iterates over a list of commands, adding them to the application’s command list and adding a new CommandBar for them:

    public class MyCommandDef {
      public String Name;
      public String MenuText;
      public String Binding;
    }
    
    ...
    
     foreach (MyCommandDef command in CommandList.Commands) {
       try {
         Command newCmd = commands.AddNamedCommand(_addInInstance, command.Name, command.MenuText, "", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled);
         if (command.Binding != null) {
           newCmd.Bindings = command.Binding;
         }
         CommandBarControl newCmdControl = (CommandBarControl)newCmd.AddControl(myCommandBar, myCommandBar.accChildCount + 1);
         if (lastCategory != command.Category) {
           // add a separator. how?
           if (newCmdControl!=null) {
             newCmdControl.BeginGroup=true;
           }
           lastCategory = command.Category;
         }
        } 
        catch (System.ArgumentException) {
          // command already exists, or has a space in it
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a windows form in Visual Studio, I want to be able
I want to be able to create a GUID/UUID on the iPhone and iPad.
In Delphi, I want to be able to create an private object that's associated
I'm trying to create a webapplication where I want to be able to plug-in
I create a file in JavaScript. Now I want to be able to make
I want to be able to do this. MyInterface interface = new ServiceProxyHelper<ProxyType>(); Here's
I want to be able to create the XSD file for my typed dataset
In Visual Studio land, I used to be able to define a structure in
Following on from this question... how do you tell the visual studio project type
I would like to create a new kind of project type for Visual Studio

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.