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!

20 Comments

  • https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=32 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?

  • https://secure.gravatar.com/avatar/13c44ef2d9d79dcca761a584be868def?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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?

  • https://secure.gravatar.com/avatar/ab4ec2858cfdf1e44dadf8c50fae314d?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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!

  • https://secure.gravatar.com/avatar/ab4ec2858cfdf1e44dadf8c50fae314d?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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 :)

  • https://secure.gravatar.com/avatar/43f0d697697daa6fe8c34188e0f3a4e6?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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.

  • https://secure.gravatar.com/avatar/ab4ec2858cfdf1e44dadf8c50fae314d?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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.

  • https://secure.gravatar.com/avatar/2ce1caed08e504213c3d439bea7e50d0?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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

  • https://secure.gravatar.com/avatar/e1a4c2b21a5186e0b27c1c601f418b76?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G Pieter van der Westhuizen says:

    Hi Ruben

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

    Good luck!

  • https://secure.gravatar.com/avatar/0542814e4dc0b9fdf2120aecbbd8df7b?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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,

  • https://secure.gravatar.com/avatar/ab4ec2858cfdf1e44dadf8c50fae314d?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G Dmitry Kostochko (Add-in Express Team) says:

    Hi Faisal,

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

  • https://secure.gravatar.com/avatar/0542814e4dc0b9fdf2120aecbbd8df7b?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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.

  • https://secure.gravatar.com/avatar/ab4ec2858cfdf1e44dadf8c50fae314d?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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.

  • https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=32 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.

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

  • https://secure.gravatar.com/avatar/ab4ec2858cfdf1e44dadf8c50fae314d?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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?

  • https://secure.gravatar.com/avatar/0542814e4dc0b9fdf2120aecbbd8df7b?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G Faisal says:

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

  • https://secure.gravatar.com/avatar/ab4ec2858cfdf1e44dadf8c50fae314d?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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.

  • https://secure.gravatar.com/avatar/0542814e4dc0b9fdf2120aecbbd8df7b?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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.

  • https://secure.gravatar.com/avatar/29957f26ad2d8ba527fd9cc8cfa7b2e0?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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.

  • https://secure.gravatar.com/avatar/ebd04a9ae763226b9523ba03d3ad365d?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G 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.

  • https://secure.gravatar.com/avatar/e1a4c2b21a5186e0b27c1c601f418b76?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G Pieter van der Westhuizen says:

    Hi Alex,

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

    Hope this helps!

Post a comment

Have any questions? Ask us right now!