我们为Visual Studio 2008开发了一个AddIn,它在“项目”上下文菜单中(右键单击解决方案资源管理器中的项目)安装命令栏项目。下面,简化代码(Connect.cs)工作正常,我们所有的机器,除了一个:命令栏控件不会显示
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;
在一台机器,代码将没有异常运行,但按钮不会显示出来。由于已存在的命令栏项目,再次调用安装代码将引发异常。但是,应该位于“工具”菜单中的另一个项目已正确安装并显示。
即使重新安装了操作系统和Visual Studio,问题仍然存在(Windows 7 x86 SP1德语,Visual Studio开发版SP1英语)。我们有其他机器具有相同的操作系统和VS配置,但按钮显示正确。
欢迎您就此主题发表任何提示!