已成功創建頂級菜單項,試圖創建的第一個孩子項目,但沒有出現,沒有異常被拋出...如何Visual Studio的外接程序 - 子菜單項未出現
void IDTExtensibility2.OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_ApplicationObject = (DTE2)application;
_AddInInstance = (AddIn)addInInst;
if (connectMode == ext_ConnectMode.ext_cm_Startup)
{
object[] contextGUIDS = new object[] { };
Commands2 commands = (Commands2)_ApplicationObject.Commands;
CommandBars commandBars = (CommandBars)_ApplicationObject.CommandBars;
CommandBar cbMainMenu = commandBars["MenuBar"];
try
{
// ROOT MENU
CommandBarPopup cbpProjectManagement = (CommandBarPopup)cbMainMenu.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, cbMainMenu.Controls.Count, true);
cbpProjectManagement.Caption = "ROOTMENU";
// SUB ITEM
Command cmdCompiledAssemblies = _ApplicationObject.DTE.Commands.AddNamedCommand(_AddInInstance, "VSPM_CA", "CA",
String.Empty, true, 0, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled);
CommandBarControl cbcCompiledAssemblies = (CommandBarControl)cmdCompiledAssemblies.AddControl(cbpProjectManagement.CommandBar, 1);
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.ToString());
}
}
}
任何有關它的解決方案嗎? – Kiquenet 2011-08-16 12:14:28