0
我創建一個Visual Studio插件,但它增加了自己,當我一次又一次地打開Visual Studio。現在我有20個菜單在我的Visual Studio :)的Visual Studio插件始終將自身添加到菜單
如何檢查的,它已經加入或不?
我用Connect.cs下面的代碼[OnStartupComplete方法]
我看了有關添加分辯菜單此視頻http://msdn.microsoft.com/en-us/vstudio/bb614548.aspx
Command command = null;
CommandBarControl commandBarControl;
CommandBar commandBarASPX, commandBarCS;
CommandBars commandBars;
try
{
try
{
command = _applicationObject.Commands.Item(_addInInstance.ProgID + "." + AddInName);
}
catch
{
}
if (command == null)
{
command = _applicationObject.Commands.AddNamedCommand(_addInInstance, AddInName, AddInButtonName, AddInButtonTooltip, true, 528, null, (int)vsCommandStatus.vsCommandStatusEnabled | (int)vsCommandStatus.vsCommandStatusSupported);
}
else
{
commandBars = _applicationObject.CommandBars as CommandBars;
commandBarASPX = commandBars["ASPX Context"];
commandBarControl = command.AddControl(commandBarASPX, commandBarASPX.Controls.Count + 1) as CommandBarControl;
commandBarCS = commandBars["Code Window"];
commandBarControl = command.AddControl(commandBarCS, commandBarCS.Controls.Count + 1) as CommandBarControl;
}
}
catch (Exception exp)
{
MessageBox.Show(exp.Message.ToString());
}