Tim
Tim

Reputation: 45

Outlook add-in continuously disabled by automatically setting HKCU RegKey to 0 at statup

A client of my outlook add-in started complaining that the add-in does not start at Outlook startup. I took a look, and each time that Outlook is started, the LoadBehaviour is set to 0.

As always, any help is greatly appreciated!

Cheers!

------EDIT----------

As requested, following is an outline of the actions happening on the OnStartupComplete method of the add-in.

The add-in is meant to provide an Outlook interface for users using the mail-like correspondence exchange component of our larger SaaS service. The add-in connects the user to our server, where they have mail-like items (html formatted) received from other users. The add-in will create a local PST file and create mail items within that PST with the HTML & attachments set as the content. The add-in will also detect if the user is attempting to reply/fwd one of the created 'mails' and override the default process in order to display a web page from the server. The server sync process is triggered at the same frequency as the Outlook Send/receive by adding a handler to the Session.SyncObjects[1].SyncStart event. the sync process itself is handled in a separate BackgroundWorker process.

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
}

Upvotes: 0

Views: 1183

Answers (1)

usselite
usselite

Reputation: 816

To start off, I don't think anyone can give a direct answer without some code or error. But maybe some extra checks can help you out.

Add-ins are disabled here in the registry, under this node:

Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\1x.0\Outlook\Resiliency\DisabledItems

(your add-in should not be listed here!)

What might happen is that the add-in crashes while closing.

Sometimes Outlook does not show you a crash/error, to change that behavior this is really helpful:

Set 'VSTO_SUPPRESSDISPLAYALERTS' with value '0' as a system variable under system > advanced > environment variables,.

https://www.oneplacesolutions.com/support/0053.html

In case the add-in is slow at start-up take a look at, as the Outlook resiliency logic might cause thing behavior. https://blogs.msdn.microsoft.com/emeamsgdev/2017/08/02/outlooks-slow-add-ins-resiliency-logic-and-how-to-always-enable-slow-add-ins/

Upvotes: 1

Related Questions