473,395 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Visual Studio 2005 add-in : my button doesn't appear in Tools menu

Hi,
I build an add-in for Visual Studio 2005.
I use the wizzard, I fixed the bug with envdte reference and build my
project immediately after the wizzard.
All seems to work, the add-in is shown in add-in Manager window, but no
button appears in Tools window.

Here is my code:

namespace MyAddinTest
{
using System;
using Microsoft.VisualStudio.CommandBars;
using Extensibility;
using EnvDTE;
using EnvDTE80;

/// <summary>The object for implementing an Add-in.</summary>
/// <seealso class='IDTExtensibility2' />
public class Connect : Object, IDTExtensibility2, IDTCommandTarget
{
/// <summary>Implements the constructor for the Add-in object. Place
your initialization code within this method.</summary>
public Connect()
{
}

/// <summary>Implements the OnConnection method of the
IDTExtensibility2 interface. Receives notification that the Add-in is
being loaded.</summary>
/// <param term='application'>Root object of the host
application.</param>
/// <param term='connectMode'>Describes how the Add-in is being
loaded.</param>
/// <param term='addInInst'>Object representing this Add-in.</param>
/// <seealso class='IDTExtensibility2' />
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)
{
object []contextGUIDS = new object[] { };
Commands2 commands = (Commands2)applicationObject.Commands;

try
{
CommandBar menuBarCommandBar;
CommandBarControl toolsControl;
CommandBarPopup toolsPopup;
CommandBarControl commandBarControl;

//Add a command to the Commands collection:
Command command = commands.AddNamedCommand2(addInInstance,
"MyAddinTest", "MyAddinTest", "Executes the command for MyAddinTest",
true, 59, ref contextGUIDS,
(int)vsCommandStatus.vsCommandStatusSupported+(int )vsCommandStatus.vsCom
mandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText,
vsCommandControlType.vsCommandControlTypeButton);

String toolsMenuName;
try
{
//If you would like to move the command to a different menu,
change the word "Tools" to the
// English version of the menu. This code will take the culture,
append on the name of the menu
// then add the command to that menu. You can find a list of all
the top-level menus in the file
// CommandBar.resx.
System.Resources.ResourceManager resourceManager = new
System.Resources.ResourceManager("MyAddinTest.Comm andBar",
System.Reflection.Assembly.GetExecutingAssembly()) ;
System.Threading.Thread thread =
System.Threading.Thread.CurrentThread;
System.Globalization.CultureInfo cultureInfo =
thread.CurrentCulture;
toolsMenuName =
resourceManager.GetString(String.Concat(cultureInf o.TwoLetterISOLanguage
Name, "Tools"));
}
catch(Exception)
{
//We tried to find a localized version of the word Tools, but one
was not found.
// Default to the en-US word, which may work for the current
culture.
toolsMenuName = "Tools";
}

//Place the command on the tools menu.
//Find the MenuBar command bar, which is the top-level command bar
holding all the main menu items:
menuBarCommandBar =
((CommandBars)applicationObject.CommandBars)["MenuBar"];

//Find the Tools command bar on the MenuBar command bar:
toolsControl = menuBarCommandBar.Controls[toolsMenuName];
toolsPopup = (CommandBarPopup)toolsControl;

//Find the appropriate command bar on the MenuBar command bar:
commandBarControl =
(CommandBarControl)command.AddControl(toolsPopup.C ommandBar, 1);
}
catch(Exception)
{
}
}
}

/// <summary>Implements the OnDisconnection method of the
IDTExtensibility2 interface. Receives notification that the Add-in is
being unloaded.</summary>
/// <param term='disconnectMode'>Describes how the Add-in is being
unloaded.</param>
/// <param term='custom'>Array of parameters that are host application
specific.</param>
/// <seealso class='IDTExtensibility2' />
public void OnDisconnection(ext_DisconnectMode disconnectMode, ref
Array custom)
{
}

/// <summary>Implements the OnAddInsUpdate method of the
IDTExtensibility2 interface. Receives notification when the collection
of Add-ins has changed.</summary>
/// <param term='custom'>Array of parameters that are host application
specific.</param>
/// <seealso class='IDTExtensibility2' />
public void OnAddInsUpdate(ref Array custom)
{
}

/// <summary>Implements the OnStartupComplete method of the
IDTExtensibility2 interface. Receives notification that the host
application has completed loading.</summary>
/// <param term='custom'>Array of parameters that are host application
specific.</param>
/// <seealso class='IDTExtensibility2' />
public void OnStartupComplete(ref Array custom)
{
}

/// <summary>Implements the OnBeginShutdown method of the
IDTExtensibility2 interface. Receives notification that the host
application is being unloaded.</summary>
/// <param term='custom'>Array of parameters that are host application
specific.</param>
/// <seealso class='IDTExtensibility2' />
public void OnBeginShutdown(ref Array custom)
{
}

/// <summary>Implements the QueryStatus method of the IDTCommandTarget
interface. This is called when the command's availability is
updated</summary>
/// <param term='commandName'>The name of the command to determine
state for.</param>
/// <param term='neededText'>Text that is needed for the
command.</param>
/// <param term='status'>The state of the command in the user
interface.</param>
/// <param term='commandText'>Text requested by the neededText
parameter.</param>
/// <seealso class='Exec' />
public void QueryStatus(string commandName, vsCommandStatusTextWanted
neededText, ref vsCommandStatus status, ref object commandText)
{
if(neededText ==
vsCommandStatusTextWanted.vsCommandStatusTextWante dNone)
{
if(commandName == "MyAddinTest.Connect.MyAddinTest")
{
status =
(vsCommandStatus)vsCommandStatus.vsCommandStatusSu pported|vsCommandStatu
s.vsCommandStatusEnabled;
}
}
}

/// <summary>Implements the Exec method of the IDTCommandTarget
interface. This is called when the command is invoked.</summary>
/// <param term='commandName'>The name of the command to
execute.</param>
/// <param term='executeOption'>Describes how the command should be
run.</param>
/// <param term='varIn'>Parameters passed from the caller to the
command handler.</param>
/// <param term='varOut'>Parameters passed from the command handler to
the caller.</param>
/// <param term='handled'>Informs the caller if the command was
handled or not.</param>
/// <seealso class='Exec' />
public void Exec(string commandName, vsCommandExecOption
executeOption, ref object varIn, ref object varOut, ref bool handled)
{
handled = false;
if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if(commandName == "MyAddinTest.Connect.MyAddinTest")
{
handled = true;
return;
}
}
}
private DTE2 applicationObject;
private AddIn addInInstance;
}
}

Thanks in advance for your help.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
0 1507

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: jmespinosabaviera | last post by:
1) Does visual studio standard 2005 include visual basic ?. 2) What difference is there between the visual studio standard 2005 and the professional version ? 3) What difference is there...
1
by: micky | last post by:
i've download vs studio team suite but it look like beta 2 CTP versio such as folder structure.. there are msdn, visio, vs ,vss folder and to check version this iso file i opened setup.ini and...
4
by: Andrew Robinson | last post by:
My main dev machine has WinXp and VS2005 (pro). 1. I need to install VWD Express Edition so that I can do some instruction on this. Any issues with both on the same machine. Installation order?...
2
by: Ravimama | last post by:
Hi All, I have not yet seen Visual Studio 2005 and I could not collect much information on this. I just want to know whether Visual Stdio 2005 is enhanced Visual Studio ..net 2003 or is it...
2
by: Nathan Sokalski | last post by:
I have a webhost that unfortunately does not yet support ASP.NET 2.0. This would not be a problem, except for the fact that most places no longer sell Visual Studio .NET 2003, which means I need to...
1
by: Dane | last post by:
Does anyone know how to add Users to Groups using Visual Studio.net 2005? I am also trying to add them to the correct OU and finally I would like to change the directory to where there terminal...
4
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
We have to upgrade our Visual Studio .NET 2003 enterprise edition to .NET 2005. However, there is no enterprise edition for Visual Studio .NET 2005. There are 4 versions available for visual...
0
by: marathoner | last post by:
I am currently migrating my Visual C++ 6.0 applications to Visual Studio 2005. I am getting compiler errors involving the VS2005's platform SDK. When I removed directory references to that SDK,...
1
by: Dr T | last post by:
Hi! I downloaded MS Visual Web Developer 2005 Express Edition, MS .NET Framework SDK v2.0, and MS SQL Server 2005. Subsequently, I bought MS Visual Studio 2005 Professional Edition. 1) Are...
7
by: =?Utf-8?B?UHJhamFrdGE=?= | last post by:
We have an application build on Microsoft Visual Studio 2002 .Net 1.0 ie on 32 bit. Can we port the same application for .NET 2.0. Does .NET 2.0 is supported on Microsoft Visual studio 2002 ie for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.