VS2013 Pro SP 4
赢 8.1 x64
我有两个 OleMenuCommands 添加到"工具"菜单中。 我已经给了他们一个BeforeQueryStatus事件的处理程序。
我已将调试代码添加到 OnBeforeQueryStatus() 中,该代码显示正在调用处理程序,并且正在选择正确的文本。 但是,"工具"菜单上的两个菜单项未正确更新。 这是OnBeforeQueryStatus():
private void OnBeforeQueryStatus(object sender, EventArgs e)
{
DbgMessage("OnBeforeQueryStatus");
var myCommand = sender as OleMenuCommand;
if (null != myCommand)
{
if (myCommand.CommandID.ID == (int)PkgCmdIdList.CmdIdCBAutoSave)
{
myCommand.Text = _autosaveEnabled ? "Disable Document AutoSave" : "Enable Document AutoSave";
DbgMessage(myCommand.Text);
}
if (myCommand.CommandID.ID == (int)PkgCmdIdList.CmdIdCBAutoSaveProject)
{
myCommand.Text = _autosaveProjectEnabled ? "Disable AutoSaveProject" : "Enable AutoSaveProject";
myCommand.Enabled = _autosaveEnabled;
DbgMessage(myCommand.Text);
}
DbgMessage(string.Format("Id: {0} Text: {1}", myCommand.CommandID.ID, myCommand.Text));
}
}
在 .vsct 文件中,<Button>
元素具有
<CommandFlag>TextChanges</CommandFlag>
如何诊断出了什么问题? 这似乎不是在Win7上运行的VS2012/2013中安装的软件包的问题。
另一个奇怪的观察结果是:当我调试VSPackage(通过使用/RootSuffix Exp参数启动devenv.exe时,菜单项会按预期更新。
添加<CommandFlag>NoCache</CommandFlag>