【问题标题】:VSTO Outlook Addin Ribbon Group Not Showing on RibbonVSTO Outlook 插件功能区组未显示在功能区上
【发布时间】:2015-07-28 16:48:28
【问题描述】:

我有一个使用两个按钮将组添加到功能区的 Outlook 插件。在我添加第二个按钮之前它运行良好,但它们具有相同的属性,只是不同的点击处理程序。它显示在自定义功能区菜单中的正确位置,但显示为灰色。当它变灰时是什么意思,什么可能导致它?插件仍处于加载状态,并且未因插件被停用的原因列表中的任何原因而被停用。

按照这个问题的答案:Outlook addin Home tab with custom button

我能够让按钮显示在主选项卡上的阅读邮件窗口中。与该答案的唯一区别是我使用了 TabReadMessage 而不是 TabMail (根据文档)。在添加第二个按钮之前,这非常有效。您可以在屏幕截图中看到这两个按钮,存档消息和存档消息。

看图:

任何人都知道为什么会发生这种情况。为什么添加第二个按钮会使其停止显示?

有没有办法调试它并查看发生了什么?

任何帮助将不胜感激,因为我一直在寻找答案。

谢谢

编辑:

为我的功能区元素的属性生成的代码。

    private void InitializeComponent()
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OutlookRibbon));
        this.tab1 = this.Factory.CreateRibbonTab();
        this.group1 = this.Factory.CreateRibbonGroup();
        this.button1 = this.Factory.CreateRibbonButton();
        this.button2 = this.Factory.CreateRibbonButton();
        this.tab1.SuspendLayout();
        this.group1.SuspendLayout();
        // 
        // tab1
        // 
        this.tab1.ControlId.ControlIdType = Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Office;
        this.tab1.ControlId.OfficeId = "TabReadMessage";
        this.tab1.Groups.Add(this.group1);
        this.tab1.Label = "TabReadMessage";
        this.tab1.Name = "tab1";
        // 
        // group1
        // 
        this.group1.Items.Add(this.button1);
        this.group1.Items.Add(this.button2);
        this.group1.Label = "Archive";
        this.group1.Name = "group1";
        this.group1.Position = this.Factory.RibbonPosition.BeforeOfficeId("GroupRespond");
        // 
        // button1
        // 
        this.button1.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
        this.button1.Description = "Archive Message";
        this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
        this.button1.Label = "Archive Message";
        this.button1.Name = "button1";
        this.button1.ScreenTip = "Archives Message";
        this.button1.ShowImage = true;
        this.button1.SuperTip = "Archives Message";
        this.button1.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button1_Click);
        // 
        // button2
        // 
        this.button2.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
        this.button2.Description = "Archive Message As";
        this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image")));
        this.button2.Label = "Archive Message As";
        this.button2.Name = "button2";
        this.button2.ScreenTip = "Archive message in designated place";
        this.button2.ShowImage = true;
        this.button2.SuperTip = "Archives message in designated place";
        this.button2.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button2_Click);
        // 
        // OutlookRibbon
        // 
        this.Name = "OutlookRibbon";
        this.RibbonType = resources.GetString("$this.RibbonType");
        this.Tabs.Add(this.tab1);
        this.Load += new Microsoft.Office.Tools.Ribbon.RibbonUIEventHandler(this.OutlookRibbon_Load);
        this.tab1.ResumeLayout(false);
        this.tab1.PerformLayout();
        this.group1.ResumeLayout(false);
        this.group1.PerformLayout();

    }

编辑 2:

突然之间,VS 中的每一个插件都会导致出现错误 Ribbon_GetDCVisible 说调用函数 GetVisisble 时发生异常。不知道为什么,但我打开了显示 UI 错误,所以也许这会使它们变灰?不过不确定,因为每个插件都会发生这种情况。甚至是全新的空白。

【问题讨论】:

  • 你能给我们看看代码吗?
  • 这是一段很好的代码。不确定要准确显示哪些部分。应该在启动时运行的代码的唯一部分是正常的 VSTO 插件代码和一些被添加到 dict 的东西。我想我可以发布功能区元素的属性。
  • 看起来不错,奇怪的是它对一个按钮的工作方式,但添加第二个按钮是隐藏的。我有几个建议。 a) 打开日志记录,我的第 7 点 here 和 b) 尝试将按钮放在不同的选项卡上,看看是否可以缩小问题域的范围,尝试在 .group1.Items.Add(this.button1); 之前指定按钮名称,尝试制作带有 XML 的按钮,或者看看你是否可以这样做:stackoverflow.com/questions/17216199/…
  • 会试一试并报告,谢谢。添加第二个按钮会产生这种影响是很奇怪的,我添加的唯一其他东西是 2 个表单,但它们非常基本并且在启动时不会被调用,所以它应该无关紧要
  • 至于你在那个答案中的第 7 点,我只是设置了那些环境变量? VSTO 日志警报出现在哪里?

标签: c# outlook vsto outlook-addin


【解决方案1】:

灰色按钮表示您的自定义 UI 已禁用。很可能您在标记中遇到了错误,或者您的代码引发了异常。 Office 应用程序禁用行为异常的加载项。

我对最初的帖子有很多问题,所以决定也将它们作为答案发布。很难将它们全部识别为评论。其中任何一个都可能导致问题的解决。

到目前为止,您有哪些 XML 标记?您是否尝试从功能区设计器中提取它?

添加其他按钮后,您是否在 Outlook 中遇到任何 UI 错误?请参阅How to: Show Add-in User Interface Errors 了解更多信息。

getVisible 回调中有什么异常?你试过调试代码吗?

【讨论】:

    猜你喜欢
    • 2021-06-03
    • 2018-05-07
    • 2021-06-13
    • 2013-03-08
    • 2018-08-29
    • 2020-08-15
    • 1970-01-01
    • 2015-12-17
    • 2022-05-17
    相关资源
    最近更新 更多