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 8997385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:52:56+00:00 2026-06-15T23:52:56+00:00

we developed an AddIn for Visual Studio 2008 which installs a command bar item

  • 0

we developed an AddIn for Visual Studio 2008 which installs a command bar item in the “Project” context menu (right click on a project in solution explorer). The following, simplified code (in Connect.cs) works fine for all of our machines except one:

object[] contextGUIDS = new object[] { };

string commandName = "My_Command";
string tooltip = "My tooltip";

Command projectCommand = applicationObject.Commands.AddNamedCommand(addInInstance, commandName, commandName, tooltip, false, 1, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled);

CommandBars commandBars = (CommandBars)(fApplicationObject.CommandBars);

CommandBar projectCommandBar = commandBars["Project"];

CommandBarControl projectButton = (CommandBarControl)(projectCommand.AddControl(projectCommandBar, projectCommandBar.Controls.Count + 1));

projectButton.Caption = "My caption";
projectButton.TooltipText = tooltip;

On one single machine, the code will run without an exception, but the button won’t show up. Invoking the installation code once more will throw an exception because of an already existing command bar item. However, another item, which should be located in the “Tools” menu is installed and shown properly.

Even though the OS and Visual Studio have been re-installed, the problem still remains (Windows 7 x86 SP1 German, Visual Studio Development Edition SP1 English). We have other machines with the same OS and VS configuration, but the button shows up there properly.

Any hints on this topic are welcome!

  • 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-06-15T23:52:57+00:00Added an answer on June 15, 2026 at 11:52 pm

    Because there is more than one command bar named Project in Visual Studio 2008, you need to find the correct one to insert the button into. Luckily, there’s an absolutely simple, reasonable and intuitive way to do that.

    1. Finding the unique ID of a command bar

    Open the registry editor and navigate to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\General. Create a new DWORD value named EnableVSIPLogging and set the value to 1.

    That allows you to determine the unique GUID and command ID of the command bar by right clicking the control you want to insert a control into while the SHIFT and CTRL modifiers are pressed. That will bring up a message box like this:

    Visual Studio 2008 Debugging Message

    Copy the contents of the message by pressing CTRL + C and paste it somewhere into a textbox. Note down the Guid and the CmdID values.

    2. Fetching a command bar by Guid and CmdID

    You can use the following code snippet to fetch a command bar from the values determined above:

    private CommandBar FindCommandBar(Guid guidCmdGroup, uint menuID)
    {
      IOleServiceProvider sp = (IOleServiceProvider)fApplicationObject;
      Guid guidSvc = typeof(IVsProfferCommands).GUID;
      Object objService;
      sp.QueryService(ref guidSvc, ref guidSvc, out objService);
      IVsProfferCommands vsProfferCmds = (IVsProfferCommands)objService;
      return vsProfferCmds.FindCommandBar(IntPtr.Zero, ref guidCmdGroup, menuID) as CommandBar;
    }
    
    [ComImport, Guid("6D5140C1-7436-11CE-8034-00AA006009FA"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
    internal interface IOleServiceProvider
    {
    
      [PreserveSig]
      int QueryService([In]ref Guid guidService, [In]ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out System.Object obj);
    
    }
    

    Ensure, that the command bars are properly initialized before calling the FindCommandBar method, otherwise the call will fail with a ComException (HResult E_FAIL). Simple way to do this:

    private void EnsureInitialized()
    {
      var menuBar = ((CommandBars)fApplicationObject.CommandBars)["MenuBar"];
    }
    

    Source: http://blogs.msdn.com/b/dr._ex/archive/2007/04/17/using-ivsproffercommands-to-retrieve-a-visual-studio-commandbar.aspx

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

Sidebar

Related Questions

I've developed a outlook addin with c# 3.5, VSTO and Visual Studio 2008 for
I have Win7 64 bits, Visual Studio 2010, and I have developed an Addin
I’ve developed a windows service developed in Visual Studio 2010 which performs Exchange 2007
I have developed a Visual Studio Add-In which interacts with the Visual Studio DOM
I have developed a Outlook Addin using VSTO in Visual Studio 2010, on Windows
I have a VSTO addin for Word. Developed with Visual Studio 2010 (for Word
I have created an Excel 2007 add-in using Visual Studio 2008 and built-in project
In Visual Studio 2010, I created a dynamics package project (Y), and a dynamics
We have developed a custom visual studio workflow for SharePoint MOSS. It creates tasks
im creating a dll in MS Visual Studio 2010 Express which loads a binary

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.