首页 > 解决方案 > 通过在启动时将 HKCU RegKey 自动设置为 0,Outlook 加载项持续禁用

问题描述

我的 Outlook 加载项客户端开始抱怨加载项在 Outlook 启动时没有启动。我看了一下,每次启动 Outlook,LoadBehaviour 都设置为 0。

一如既往,非常感谢任何帮助!

干杯!

- - - 编辑 - - - - -

根据要求,以下是在加载项的 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
}

标签: c#outlook-addin

解决方案


首先,我认为没有人可以在没有代码或错误的情况下给出直接答案。但也许一些额外的检查可以帮助你。

加载项在注册表中被禁用,在此节点下:

计算机\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/


推荐阅读