【发布时间】:2019-07-11 19:04:19
【问题描述】:
我正在使用 C# 为 Outlook 开发一个简单的加载项。现在,当我在测试版本时,突然 Outlook 会打印一条错误消息并禁用我的加载项:
This add-in caused Outlook to start slowly. (1.594 seconds)
我不确定是什么原因造成的。我所做的Onload 就是这些:
功能区按钮
我正在使用一个功能区按钮,我在我的插件中初始化如下:
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
return new MyRibbonButton();
}
功能区按钮构造函数
功能区按钮初始化一个对象。所以还没有什么特别的。
public MyRibbonButton()
{
this.guiSettings = new AppSettingsManager(root.localmachine, "GUI", false);
}
...
public AppSettingsManager(root type, string subpath, bool writable)
{
if (subpath != "")
{
this.PATH += @"\" + subpath;
}
this.type = type;
this.writable = writable;
}
图标
在同一个MyRibbonButton 类中,我根据注册表中的值声明要用于按钮的图标。
public Bitmap imageSuper_GetNotifyImage(IRibbonControl control)
{
switch (guiSettings.GetValueInt32("Icon", 1))
{
case 1:
return Properties.Resources.icon1;
case 2:
return Properties.Resources.icon2;
case 3:
return Properties.Resources.icon3;
default:
return Properties.Resources.icon1;
}
}
如您所见,除了最后一部分中的注册表读取之外,我没有做任何特别的事情。您认为这会导致 Outlook 启动缓慢吗?如果是这样,我该如何优化它。
【问题讨论】:
-
我有一个插件,几乎和你的一样简单,我也遇到了同样的问题。我的只是为 3 个事件添加了侦听器。我放弃并恢复为宏
-
@BugFinder 如果您发现了什么,请告诉我。你知道如何解决这个问题吗?
-
我得出的结论是,根据前景,提供的整个 .net 框架中的某些东西已经使它“变慢”了。当我这样做是为了让我的生活更轻松,但事实证明它是什么,但是,我放弃了这个想法。
-
@BugFinder 听到这个消息很难过。不幸的是,我必须坚持使用加载项。看来我必须找到解决方法。
标签: c# outlook outlook-addin add-in