【问题标题】:Debugging vsto ribbon callbacks调试 vsto 功能区回调
【发布时间】:2023-11-01 02:06:01
【问题描述】:

我有一个 VSTO Outlook 功能区(上下文菜单),它按预期工作:

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
  <contextMenus>
    <contextMenu idMso="ContextMenuMailItem">
      <button id="DoThis"
          label="Label"
          onAction="DoThis"
          getVisible="GetVisible"/>
    </contextMenu>
</customUI>

但是,如果我有一个 getLabel 属性,那么上下文菜单将不再显示。我想我一定是搞砸了,但没有迹象表明是什么;没有日志,没有例外,什么都没有。此外,我找不到任何地方记录每个回调的定义应该是什么。我只是尝试了明显的 getLabel 应该返回一个字符串,但它似乎不起作用。 getVisible 工作得很好(返回一个布尔值)。

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
  <contextMenus>
    <contextMenu idMso="ContextMenuMailItem">
      <button id="DoThis"
          label="Label"
          onAction="DoThis"
          getVisible="GetVisible"
          getLabel="GetLabelMoveToReviewFolderMultiple"/>
    </contextMenu>
</customUI>

以及后面的代码(其他方法未展示):

[ComVisible(true)]
public class ContextMenu : Office.IRibbonExtensibility
{
    public string GetLabelMoveToReviewFolderMultiple(Office.IRibbonControl control)
    {
       return "Custom Label";
    }
}

【问题讨论】:

    标签: vsto contextmenu outlook-addin ribbon


    【解决方案1】:

    不要同时使用labelgetLabel。此外,在 File | Options | Advanced | Developer 中启用插件错误以查看所有功能区 XML 错误。

    【讨论】:

      【解决方案2】:

      好吧,在编写问题时,我尝试使用 getLabel 删除上下文菜单的标签属性,这确实解决了问题;之后上下文菜单工作正常。我(最初)认为将标签保留为默认值可能是有意义的。

      documentation 解释了什么是互斥的。

      【讨论】: