c# - 通过在启动时将 HKCU RegKey 自动设置为 0,Outlook 加载项持续禁用
问题描述
我的 Outlook 加载项客户端开始抱怨加载项在 Outlook 启动时没有启动。我看了一下,每次启动 Outlook,LoadBehaviour 都设置为 0。
该加载项使用 C# 4.0 编写为托管 COM 加载项(抱歉,无法更改它 - 旧工具)。
它已在 HKLM 上为所有用户注册。
客户端正在运行 Outlook 365 ProPlus 版本 1708(内部版本 8431.22.42 即点即用)32 位 (16.0.84.31.2110)
客户端机器是 Windows 10 64 位。
不断重置为 0 的 HKCU 级别 LoadBehaviour 密钥在 Software\Microsoft\Office.. 节点上生成(而不是在 Software\Wow6432Node... 下)
该加载项出现在 Outlook 的“非活动应用程序加载项”列表下,但不会通过界面启用(您可以设置它,但它不会启用)。
在“缓慢和禁用的 COM 加载项”列表中标记为“始终启用”的加载项。
这是加载项列表中列出的唯一通过 mscoree.dll 加载的加载项(我知道是否有另一个 mscoree.dll 加载项并且被禁用,那么我们的加载项也会被禁用)。
我通过 RegEdit 手动将 HKCU LoadBehaviour 更改为 3,并在下次打开 Outlook 时加载加载项,但在下次重新启动 Outlook 时,加载项被禁用并且 LoadBehaviour 再次设置为 0。
似乎没有其他客户端遇到此问题,我也无法在 Outlook 365 的本地实例上复制该问题。
一如既往,非常感谢任何帮助!
干杯!
- - - 编辑 - - - - -
根据要求,以下是在加载项的 OnStartupComplete 方法上发生的操作的概要。
该插件旨在为使用我们更大 SaaS 服务的类似邮件的通信交换组件的用户提供 Outlook 界面。插件将用户连接到我们的服务器,在那里他们从其他用户那里收到类似邮件的项目(html 格式)。该插件将创建一个本地 PST 文件并在该 PST 中创建邮件项目,并将 HTML 和附件设置为内容。该插件还将检测用户是否正在尝试回复/转发其中一个已创建的“邮件”并覆盖默认进程以显示来自服务器的网页。通过向 Session.SyncObjects[1].SyncStart 事件添加处理程序,以与 Outlook 发送/接收相同的频率触发服务器同步过程。同步进程本身在单独的 BackgroundWorker 进程中处理。
public void OnStartupComplete()
{
if (_applicationObject == null)
return;
try
{
if (_applicationObject.ActiveExplorer() == null)
return;
_version = _applicationObject.Version.Split(new string[] { "." }, System.StringSplitOptions.RemoveEmptyEntries);
StaticGlobals.OutlookVersionString = _applicationObject.Version;
StaticGlobals.OLIVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version ;
StaticGlobals.OLIFileVersionString = FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).ProductVersion;
//This class has all the processes of my add-in process.
_addinControlObj = new AddInControlerClass();
//Get references to application, explorer objects
_addinControlObj.ApplicationObject = _applicationObject;
_explorers = _addinControlObj.ApplicationObject.Explorers;
//tracks creation of new explorer & inspector windows in order to override reply/fwd actions on specific scenarios (it provides extra options for the user before opening mail editor)
_explorers.NewExplorer += this.Open_NewExplorer;
_currentExplorer = _addinControlObj.ApplicationObject.ActiveExplorer();
_addinControlObj.ApplicationObject.Inspectors.NewInspector += this.Open_NewInspector;
//Create redemption object
_rdoSession = Redemption.RedemptionLoader.new_RDOSession();
_rdoSession.MAPIOBJECT = _addinControlObj.ApplicationObject.Session.MAPIOBJECT;
((Microsoft.Office.Interop.Outlook.ApplicationEvents_11_Event)_applicationObject).Quit += ReleaseComObjects;
((Microsoft.Office.Interop.Outlook.ApplicationEvents_11_Event)_applicationObject).ItemSend += SendMail;
}
catch (System.Exception ex)
{
Common.HandleErrors(ex, "On Connection", false, null, "", StaticGlobals.OutlookVersionString);
}
try
{
OutlookCommands olCommands = new OutlookCommands();
//Get PST file name with Outlook user name suffixed. Common.GetAppPath() will point to a sub folder within either %UserProfile%\AppData\Local or user pre-defined location
_addinControlObj.FilePath = Path.Combine(Common.GetAppPath(), olCommands.GetFileNameUserSpecific(_addinControlObj.ApplicationObject, "addinCreatedDataFileName.pst"));
_addinControlObj.CreateProjectConnections(); // connects to the server to retreive access token for API
}
catch (System.Exception ex)
{
Common.HandleErrors(ex, "On startup complete - Get and validate proj details", true, null, "", StaticGlobals.OutlookVersionString);
}
try
{
//region create PST store and sub-folders
_addinControlObj.CheckAndCreateFolders();
}
catch (System.Exception ex)
{
Common.HandleErrors(ex, "On startup complete - Check and create folders", true, null, "", StaticGlobals.OutlookVersionString);
}
#region add add-in sync method to Outlook send/receive all object
try
{
if (_addinControlObj.ApplicationObject.Session.SyncObjects.Count > 0)
{
_syncObject = _addinControlObj.ApplicationObject.Session.SyncObjects[1];
_syncObject.SyncStart += _syncObject_SyncStart;
}
else
{
Common.HandleErrors(null, "On startup complete - Warning - No SyncObjects accounts found.", false, null, "", StaticGlobals.OutlookVersionString);
}
}
catch (System.Exception ex)
{
Common.HandleErrors(ex, "On startup complete - Add to sync objects", true, null, Properties.Resources.SyncAttachFailMessage, StaticGlobals.OutlookVersionString);
}
#endregion
#region Define the functions for the attachment size limitation.
try
{
_attachmentSizeLimitation.application = _applicationObject;
_attachmentSizeLimitation.sessionRDO = _rdoSession;
_attachmentSizeLimitation.connect = this;
_attachmentSizeLimitation.DefineFunctions();
}
catch (System.Exception ex)
{
Common.HandleErrors(ex, "On startup complete - Initialize attachment limitation.", false, null, "", StaticGlobals.OutlookVersionString);
}
#endregion
}
解决方案
首先,我认为没有人可以在没有代码或错误的情况下给出直接答案。但也许一些额外的检查可以帮助你。
加载项在注册表中被禁用,在此节点下:
计算机\HKEY_CURRENT_USER\Software\Microsoft\Office\1x.0\Outlook\Resiliency\DisabledItems
(您的加载项不应在此处列出!)
可能发生的情况是加载项在关闭时崩溃。
有时 Outlook 不会向您显示崩溃/错误,要更改该行为,这真的很有帮助:
在系统 > 高级 > 环境变量下将“VSTO_SUPPRESSDISPLAYALERTS”设置为“0”作为系统变量。
https://www.oneplacesolutions.com/support/0053.html
如果加载项在启动时很慢,请查看,因为 Outlook 弹性逻辑可能会导致事物行为。 https://blogs.msdn.microsoft.com/emeamsgdev/2017/08/02/outlooks-slow-add-ins-resiliency-logic-and-how-to-always-enable-slow-add-ins/
推荐阅读
- javascript - 如何重构此代码以使图像文件显示在浏览器上?
- google-chrome - Chrome 扩展:如何监听启用/重新启用的事件
- microsoft-graph-api - 尝试使用 Microsoft 图形 API 将应用程序发布到目录时出现“上下文为空或 TenantId 为空或 UserId 为空”
- c++ - 向量下标超出函数范围
- java - 2 名玩家之间的骰子游戏,最高得分为 50
- bash - 分配bash变量时base64解码失败?
- .htaccess - 如何使用 .htaccess 将 https://www.example.com 重定向到 https://example.com?
- thymeleaf - 百里香片段未解决
- github - Jekyll 从生成的 URL 中删除 Github 用户名和 repo 名
- java - 问题 HQL JAVA 休眠