C# Outlook加载项在statup时自动将HKCU RegKey设置为0,从而持续禁用
“我的outlook加载项”的客户端开始抱怨加载项在outlook启动时未启动。我看了一下,每次启动Outlook时,LoadBehavior都设置为0C# Outlook加载项在statup时自动将HKCU RegKey设置为0,从而持续禁用,c#,outlook-addin,C#,Outlook Addin,“我的outlook加载项”的客户端开始抱怨加载项在outlook启动时未启动。我看了一下,每次启动Outlook时,LoadBehavior都设置为0 外接程序是用C#4.0编写的托管COM外接程序(抱歉,无法更改它-遗留工具) 为所有用户在HKLM上注册 客户端正在运行Outlook 365 ProPlus版本1708(构建8431.22.42单击运行)32位(16.0.84.31.2110) 客户端计算机是Windows 10 64位 在Software\Microsoft\Office
- 外接程序是用C#4.0编写的托管COM外接程序(抱歉,无法更改它-遗留工具)
- 为所有用户在HKLM上注册
- 客户端正在运行Outlook 365 ProPlus版本1708(构建8431.22.42单击运行)32位(16.0.84.31.2110)
- 客户端计算机是Windows 10 64位
- 在Software\Microsoft\Office上生成不断重置为0的HKCU级别LoadBehavior键。。节点(与软件下的相反\Wow6432Node…)
- 外接程序显示在Outlook的“非活动应用程序外接程序”列表下,但不会通过界面启用(您可以设置它,但它不会启用)
- 在“慢速和禁用COM加载项”列表中标记为“始终启用”的加载项
- 这是通过加载项列表中列出的mscoree.dll加载的唯一加载项(我知道如果有另一个mscoree.dll加载项被禁用,那么我们的加载项也将被禁用)
- 我通过RegEdit手动将HKCU LoadBehavior更改为3,并在下次打开Outlook时加载外接程序,但在下次重新启动Outlook时,该外接程序被禁用,LoadBehavior再次设置为0
- 似乎没有其他客户端遇到此问题,我也无法在Outlook 365的本地实例上复制此问题
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\U当前\U用户\Software\Microsoft\Office\1x.0\Outlook\Resilience\DisabledItems (此处不应列出您的加载项!) 可能发生的情况是,加载项在关闭时崩溃 有时Outlook不会显示崩溃/错误,要更改该行为,这非常有用: 将值为“0”的“VSTO_SUPPRESSDISPLAYALERTS”设置为系统变量 在系统>高级>环境变量下 如果外接程序在启动时速度较慢,请查看,因为Outlook弹性逻辑可能会导致某些行为。
嗨,美国精英,感谢您的回复!我终于与客户取得了联系,并在屏幕上分享了您的建议。我已经排除了外接程序崩溃的可能性,因为当我手动加载它时,它会工作。它没有列在Resilience\DisabledItems节点下,而是列在DonotDisabledInList下。正如我所提到的,它是一个托管COM加载项(因此“位置”字段显示“mscoree.dll”),因此VSTO_SUPPRESSDISPLAYALERTS不会有帮助。我知道很难指出非代码问题,虽然我假设这是一个安装/启动问题,但我无法理解,非常感谢您的帮助。您能分享一些代码吗?比如创业公司里有什么?根据我自己在Outlook 2016和Outlook 2019(Office 365更新后)之间的经验,我知道在更新后,我突然出现了一个问题,无法将外接程序附加到邮件项。我必须改变功能区初始化的一些行为。另外,您是否在加载项中使用MAPI?您好@usselite,我已使用OnStartupComplete的代码更新了OP是的,我确实使用MAPI,但主要是通过兑换。与邮件项目的连接未在StartupComplete中完成。我在没有连接的情况下也进行了测试(我所有的方法都会检查是否定义了连接,否则就返回),但在下一次启动时该外接程序仍然被禁用。只是出于好奇,您是否为该外接程序构建了安装程序?-此行为是在外接程序更新后开始的吗?客户端能否验证他们没有安装两个版本的外接程序?看起来您使用Outlook Redemption,这是最新的吗?我在可用代码中看不到任何特定的MAPI交互,也许可以尝试捕获所有与该交互的交互。