Pieter van der Westhuizen

How to avoid “Outlook detected a problem with an add-in”. Tips & tricks for Office 2013 developers

If you’ve read my last article What’s new in Outlook 2013 for developers, you would’ve seen I mentioned that Outlook 2013 has become a lot stricter when checking add-in performance for such metrics as add-in start-up, shutdown, item open and folder switching.

If you do have a few misbehaving plug-ins, you might also have seen this new information bar when starting Outlook 2013 “A problem was detected with an add-in and it has been disabled”.

A problem was detected with an add-in and it has been disabled

Clicking on the “View Disabled Add-ins…” button shows you a form with all the slow add-ins as well as exactly how slow each add-in was with a Red Bar of Slowness: “These add-ins decreased performance or caused Outlook to start slowly”.

Red Bar of Slowness in Outlook 2013

Speaking for myself, I would not like this to happen to my Outlook add-ins. It does not help your users’ confidence in your plug-in if they see this horrible red bar and realise just how much time your add-in took from their lives, by having to wait for it to perform its function.

The new Outlook performance monitoring criteria include:

  • Add-in Start-up = 1000 milliseconds
  • Add-in Shutdown = 500 milliseconds
  • Folder switch = 500 milliseconds
  • Item open = 500 milliseconds

Outlook does give each add-in a fair chance, however, by using the average start up time over five consecutive iterations i.e. If your add-in misbehaves and on average takes longer than one second to load, Outlook will disable it and show the user a notification with which they can choose to always enable the add-in or keep it disabled… just imaging those support calls! The same goes for the other criteria, your Outlook plug-in gets five strikes and it’s out.

So let’s have a look at how you can avoid the dreaded Red Bar of Slowness and “A problem was detected with an add-in…” in Outlook 2013:

Slow start-up: This add-in caused Outlook to start slowly

The AddinInitialize is a tempting place to put code that checks for numerous things e.g. licensing, trial expiration etc. It is a good idea to defer long running processes to another part of your add-in to avoid it being disabled by Outlook 2013’s strict policies.

If you are not using any Outlook objects you can always kick off a background thread to do the work for you. This is ideal for situations where you’d want to call a web service to check the users’ license etc. However, be aware that any background thread in your add-in does incur some overhead and it is absolutely NOT a good idea to access the Outlook object model from any thread other than the main thread. Andrei wrote a good article about this – On using threads in managed Office extensions, if you need more information about this challenge.

I do have some good news. From version 7 of the Add-in Express Loader, your add-in is loaded on demand rather than on Outlook start-up, this allows your plugin to bypass the most critical criteria on the add-in’s loading time. The add-in will be loaded by the loader on first call of such methods as GetCustomUI.

This was done as part of our continuation of a trend to optimize the add-in’s performance, and just another reason why I always say that Add-in Express got your back when it comes to Office extensions.

Slow shutdown: This add-in caused Outlook to close slowly

In Outlook 2013, you have 500 milliseconds to completely shut down your add-in. That’s half a second! As with the start-up event, Outlook calculates the average of 5 successive shutdowns of your addin and if it’s not happy, it will disable your plug-in the next time the user starts Outlook.

Folder Switch: This add-in caused Outlook to switch folders slowly

Even though we have your back with Office extensions, we can’t keep you from optimizing your managed code. As with any type of development, you have to keep all scenarios in mind when you decide to take a specific approach.

You need to be careful with the BeforeFolderSwitch and FolderSwitch events, as there are few things as frustrating to a user as having to wait for Outlook to switch to another folder, from the user’s perspective this should occur instantaneously. So, as a general rule if I need to write logic when the user switches between folders, I hold off on making any long network or database calls. MSDN also suggests you rather cache data locally.

You can also check if the SendMessage method and OnSendMessage event is not a viable solution. I promise to write an article on how to use this method and event in the future.

ItemOpen: This add-in caused Outlook to open items slowly

Here we’re talking about the Open event on an item, and we also only have half a second before Outlook starts getting angry with us.

Again, use some creative and sensible thinking and try not to incur a lot of overhead when the user opens an Outlook item. Also, be aware that all calls to the Outlook object model happen on the main thread and that in Outlook 2013 any calls made to its object model from any other thread than the main thread, might throw a horrible E_RPC_WRONG_THREAD exception. Again, just imagine those support calls!

Don’t panic – the add-in slow performance issues can be solved!

Ok, so, we’ve seen that Outlook 2013 is even more strict that Outlook 2010 when it comes to add-in performance. Believe it or not, this is a good thing and your users will thank you for it.

As I mentioned earlier, Add-in Express has already coped with the most critical and most frequent one – add-ins’ slow start. The improved Add-in Express Loader will keep your plug-ins save from causing Outlook to start slowly and they will never end up in the “Disabled Items list”. I must say the enhanced loader is pretty spectacular, no matter what I did, I could not get Outlook to show the “Red bar of slowness” with an Add-in Express based add-in, I had to create a VSTO add-in for the screenshots :)

The other challenges (FolderSwitch and ItemOpen) can also be bypassed by keeping a level head and approaching things a bit differently.

No-one said Office development is easy, but with a little bit of common sense and support from your friendly Add-in Express team, you don’t need to worry.

Thank you for reading. Until next time, keep coding!

22 Comments

  • Carson says:

    Outlook 2010 reports in the event log the startup times for each Add-in, so we have something to gage against. Is there a way to see the reported times for Shutdown, Item Open, and Folder Switch?

  • Oliver says:

    Will time spent in the InspectorActivate-event handler also count against the ItemOpen census?

    Also, does the ADX Loader thing also apply to VCL-based/unmanaged addins?

  • Dmitry Kostochko (Add-in Express Team) says:

    Hi Carson,

    Outlook 2013 also reports the starting time of each add-in in the Event Log. I don’t know any way to see the time spent on handling the mentioned events. Even Office 2013 Telemetry Dashboard shows the loading time only. This is how things stand in the current version. Hopefully Microsoft will let us see all counters in Office 2013 RTM.

    Anyway, you can gage the time in your code, in your event handlers, using the Environment.TickCount property.

    Thank you for your comment!

  • Dmitry Kostochko (Add-in Express Team) says:

    Hi Oliver,

    The InspectorActivate event is not monitored by Outlook 2013. As for the Add-in Express Loader, there is a similar thing in the VCL edition of our product. You can add any code to the OnAddInInitialize event handler, Outlook 2013 will be patient and tolerant :)

  • Pooja says:

    Hi,

    I am not getting this warning ““A problem was detected with an add-in and it has been disabled”.”, Is anyone have idea how to enable this warning message??

    Thanks for the help in advance.
    Pooja.

  • Dmitry Kostochko (Add-in Express Team) says:

    Hi Pooja,

    Outlook 2013 triggers this warning only if your add-in is slow or throws some exceptions. So, the fact that you do not get it proves that your add-in’s code is written well and works fast. Or, do you want to emulate this scenario and force the warning to show up? If the latter, pay attention to events that are monitored by Outlook 2013 that are described in the article. You can slow down your code by calling e.g. System.Threading.Thread.Sleep(1000) and you will get the “A problem was detected with an add-in…” warning.

  • Ruben Koene says:

    Hi,

    Is it possible to change the wait time on the client? I have an add-in from a vendor who is not going to update it’s add-in. The add-in is written for Outlook 2010, but works also on 2013. But sometimes users get the warning “Outlook detected a problem with an add-in”. So if we can change the timing from 500 miliseconds, to 2000 miliseconds, we probably would not get this issue again.

    Thanks in advance.
    Regards, Ruben

  • Pieter van der Westhuizen says:

    Hi Ruben

    I’ve never tied it myself, but maybe give this workaround a try: https://www.outlook-apps.com/inactive-outlook-add-ins/
    Read the “Enabling inactive Outlook add-ins that keep being unloaded” part.

    Good luck!

  • Faisal says:

    Hi,

    My Outlook Addin throws a Security Manager exception with Outlook 2013 every time Outlook loads and on folder switch. The exception message reads as follows.

    “Application Domain: C:\Program Files\Gordano\ABC Outlook Addin\
    Assembly Codebase: file:///C:/Program Files/ABC/ABC Outlook Addin/SecurityManager.2005.DLL
    Assembly Full Name: SecurityManager.2005, Version=7.0.3140.2005, Culture=neutral, PublicKeyToken=aa42cad61af07cf4
    Assembly Version: 7.0.3140.2005

    Exception Source: SecurityManager.2005
    Exception Type: System.AccessViolationException
    Exception Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    Exception Target Site: Check

    —- Stack Trace —-
    AddinExpress.Outlook.IOutlookSecurityManager2.Check(apiType As Int32)
    SecurityManager.2005.DLL: N 00000 (0x0) JIT
    AddinExpress.Outlook.SecurityManager.set_DisableSMAPIWarnings(value As Boolean)
    SecurityManager.2005.DLL: N 0182 (0xB6) IL
    gmsaddin.AddinModule.adxOutlookEvents_ExplorerFolderSwitch(sender As Object, explorer As Object)
    SecurityManager.2005.DLL: N 0031 (0x1F) IL
    AddinExpress.MSO.ADXOutlookAppEvents.DoExplorerFolderSwitch(explorer As Object)
    SecurityManager.2005.DLL: N 0008 (0x8) IL ”

    In the event viewer it gives the following warning.

    Outlook disabled the following add-in(s): ProgID: abcaddin.AddinModule GUID: {EDB952B0-3ED3-4AC4-AB0D-59068AA9C9EC} Name: ABC Outlook Addin Description: AddinModule Load Behavior: 3 HKLM: 0 Location: c:\program files\foldername\abc outlook addin\adxloader.dll Threshold Time (Milliseconds): 500 Time Taken (Milliseconds): 1653 Disable Reason: This add-in caused Outlook to switch folders slowly. Policy Exception (Allow List): 0

    The addin is enabled in ‘Manage Addins’ in Outlook but still it is throwing this exception.

    Any help is this regard will be much appreciated!

    Thanks,

  • Dmitry Kostochko (Add-in Express Team) says:

    Hi Faisal,

    Please install the latest version of the Security Manager for Microsoft Outlook product.

  • Faisal says:

    Thanks Dmitry! This has solved my problem. However, when I try to register ADX, it hangs and does not complete. Can you please advise in this regard.

  • Dmitry Kostochko (Add-in Express Team) says:

    Hi Faisal,

    Sorry, I do not quite understand you. What do you mean by “register ADX”? Please clarify.

  • Anonymous says:

    Hi Dmitry,

    When you right click the addin project you get an option to ‘Register ADX Project’. I considered this step necessary after installing the latest ‘Add-in Express™
    for Microsoft® Office and .net’ and ‘Security Manager for Microsoft Outlook’. This problem is also addressed in the following thread.

    https://www.add-in-express.com/forum/read.php?FID=5&TID=2961

  • Dmitry Kostochko (Add-in Express Team) says:

    Hi Faisal,

    Thank you for the additional information. Do you run your Visual Studio under elevated privileges? Do you add any code to the constructor of your add-in module?

  • Faisal says:

    Yes, I run Visual Studio as administrator. A timer and Event handlers are added in the constructor of the add-in module.

  • Dmitry Kostochko (Add-in Express Team) says:

    Faisal,

    Could you please send your project (or some demo project with the same behavior) to me for testing? You can find our support email address in the readme.txt file located in the Add-in Express installation folder.

  • Faisal says:

    Thanks for your help but the registration went successful on the test machine I made for you. It still hangs on my development machine but builds successfully. Can you please clarify what problem it can cause if this process is not completed successfully.

  • Andrei Smolin (Add-in Express Team) says:

    Hello Faisal,

    I would like to access your PC remotely. Is this possible? If yes, I suggest using TeamViewer; in this case you’ll need to send me your session ID and password. Please find the support email address in {Add-in Express installation folder}\readme.txt.

  • Alex Baukov says:

    Hi guys,
    According to the following article

    https://msdn.microsoft.com/en-us/library/office/jj228679.aspx#ol15WhatsNew_AddinDisabling

    Outlook uses the median time of 5 last runs and compares it to 1 millisecond (for add-in startup). This means that if I optimize my add-in and re-install it, I should run Outlook at least 4 more times to calculate the correct value of add-in startup.
    Does anybody know where this value is stored in Outlook (I guess registry)?
    I tried to remove my add-in’s value from the following key:
    HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\AddInLoadTimes
    but it doesn’t help, it still remembers it.

  • Pieter van der Westhuizen says:

    Hi Alex,

    Try experimenting with the keys under HKCU\Software\Microsoft\Office\15.0\Outlook\Addins

    Hope this helps!

  • Triet says:

    Hi Pieter,

    “This add-in caused Outlook to switch folders slowly”
    I encountered this error when starting outlook plugin on outlook 2013 and Outlook 2016

    I tried to disable all codes in constructor of addin:
    public AddinModule()
    {
    // Nothing here
    }

    Then build plugin and run outlook over 5 times but Outlook still show that warning and disabled our plugin.

    I check your article about that error and check events:
    . BeforeFolderSwitch
    . FolderSwitch
    However in our plugin, there is such event like that.

    So far I have no clue to detect where the problem came from.
    Do you have any idea?

  • Andrei Smolin (Add-in Express Team) says:

    Hello Triet,

    As you understand that warning occurs if your add-in handles FolderSwitch and/or BeforeFolderSwitch slowly. What “slowly” means is defined at https://msdn.microsoft.com/en-us/library/office/jj228679.aspx.

    In particular, that description may mean that after you commented out the constructor, the “median time” still exceeds the threshold.

    As to what exactly causes the issue, I suppose there’s a pane in your add-in and you have some logic that works when the pane is being created. If that pane is an Add-in Express pane, it is re-created when you switch to a folder.

    I’ve sent a slightly extended version of the above in response to your email you sent to us.

Post a comment

Have any questions? Ask us right now!