VSPackage菜单项无法正确更新文本,Win8.1 [英] VSPackage menu items not updating text correctly, Win8.1

查看:62
本文介绍了VSPackage菜单项无法正确更新文本,Win8.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VS2013 Pro SP 4  Win 8.1 x64 

VS2013 Pro SP 4  Win 8.1 x64  

我在工具菜单中添加了两个OleMenuCommands.  我为他们提供了一个BeforeQueryStatus事件的处理程序.

I have two OleMenuCommands added to the Tools menu.   I have given them a handler for the BeforeQueryStatus event.

我已经在OnBeforeQueryStatus()中添加了调试代码,该代码显示正在调用处理程序,并且正在选择正确的文本.但是,工具"菜单上的两个菜单项未正确更新.  这是OnBeforeQueryStatus():

I have added debugging code to the OnBeforeQueryStatus() that shows the handler is being called, and the correct text is being selected.  However, the two menu items on the Tools menu are not correctly updated.  Here's 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));
    }
}

如何诊断出问题所在?  在Win7上运行VS2012/2013似乎不是问题.

How can I diagnose what is going wrong?  This doesn't seem to be an issue with VS2012/2013 running on Win7.

另一个奇怪的发现:当我调试VSPackage时(通过使用/RootSuffix Exp参数启动devenv.exe),菜单项会按预期更新.

Another strange observation:  When I debug the VSPackage (by starting devenv.exe with the /RootSuffix Exp argument), the menu items update as expected.


推荐答案

可能是调试器的问题,如果您卸载update4,它可以正常工作吗? AFAIK,许多bug的update4.尝试将其卸载并修复vs2013.或在带有win8.1/vs2013(不带update4)的新计算机上尝试该项目.
could be the problem with the debugger, if you uninstall update4, will it work ok? AFAIK, many bugs for update4. try uninstall it and repair vs2013. or try the project on a new machine with win8.1/vs2013(without update4).


这篇关于VSPackage菜单项无法正确更新文本,Win8.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆