views:

4203

answers:

2

For some weeks now we have been fighting with an issue where at a small number of customers our Outlook addin gets unloaded and disabled for yet undetermined reasons. By "disabled" I mean that Outlook changes the following registry value from 3 to 2 which in effect means that the addin will not be loaded on next startup:

HKEY_LOCAL_MACHINE\Software\Microsoft\Office\Outlook\Addins\[OurAddin.sProgID]\LoadBehavior

There is no error message and neither do any exceptions show up in the log files that our addin produces itself.

I have already found the following page which specifically deals with the LoadBehavior change issue: http://blogs.msdn.com/vsod/archive/2008/04/22/Troubleshooting-com-add-in-load-failures.aspx

However, none of the possible reasons proposed there appear to be applicable:

  • The addin is not merely listed in the Disabled Items list.
  • There are no unhandled exceptions neither in the IDTExtensibility2 methods nor anywhere else in the code. All code is wrapped in try/catch equivalents and all exception output is emitted only via OutputDebugString or into a log file.
  • The error appears to be independent of anti-virus software, i.e. it also occurs with it disabled.
  • Disabling all other addins also has no effect on the error.

So, what else can cause Outlook to disable an addin?

Some more details / observations:

  • We haven't been able to reproduce the issue in our test environments so far so we haven't yet been able to attach a debugger while the issue occurs.
  • The issue never occurs while we try to watch what happens via remote support (TeamViewer). I suspect this is because TeamViewer uses a hook DLL that injects itself into all running processes (including Outlook) and thus affects the memory layout, timing, thread order, whatever.
  • Whenever we compile a new version of the addin to try out something new the addin will typically work fine for a couple of hours or even days only to eventually get disabled again. Once this has happened all subsequent attempts to get the addin to load on that machine (by manually changing back the LoadBehavior value) will fail (i.e. LoadBehaviour will simply change back to 2) until we compile and deploy another build (or try to watch using TeamViewer - see above).
  • Typically the addin will get unloaded right on Outlook startup though occasionally it also does happen after Outlook has already been running for some time. The log file in those cases looks completely inconspicious - the addin simply goes through the regular shutdown steps just as if Outlook had been closed normally.
  • As far as I can tell from our log files and by observing the issue via SysInternals ProcessMonitor, when the addin get disabled on Outlook startup (rather than during the session) the DLL gets unloaded even before the COM object (i.e. the addin) gets instantiated (log messages in the constructor never show up).
  • We have put OutputDebugString messages in initialization sections (this a Delphi DLL). None of them show up when the addin fails to load.
  • Only a very small fraction of our customers is affected by this issue. We have several tens of thousands of installations from whom we haven't received any reports about this.

  • UPDATE: It seems that often (but not always) one of the last things that gets logged before the addin gets unloaded is an exception with text "OLE error 800A01A8". That exception gets caught by a global exception handler built into the framework I'm using (Add-in-Express) and does not appear originate from anywhere it my own code every single method of which is by now entirely wrapped in try..catch. This typically occurs right after I set the visibility of my CommandBarButtons from an Inspector's Activate event handler.

Common properties of all affected machines:

  • Windows XP Professional, up-to-date patch level
  • Outlook 2003 Professional, up-to-date patch level
  • varying versions of McAfee Virus Scan (though disabling it has no effect - see above)
  • Users are members of the local Administrators group

One more thing to note which very probably is significant as well (though maybe not as much as I first thought):
We are using a licensing / copy protection module from a third-party vendor which wraps the compiled DLL in a "shell" and only unpacks it on-the-fly. Ever since I found out that the addin gets unloaded even before any of our own code gets executed this has been my prime suspect. However, while the vendor confirmed that there may be unhandled exceptions in their code a log file produced by a special debug version of the protection shell showed that the unpacking process completed successfully and control was already handed back to the protected DLL before Outlook unloaded the addin. So it appears that whatever causes Outlook to unload our addin happens between the completion of the protection shell's initialization and our own code.

Any more ideas?

+1  A: 

I am also working on Outlook Add-In and I know one reason when the Add-In gets disabled. some time when Outlook shuts down abruptly or user forcefully shut down the Outlook, add-In gets disabled. I am not sure if this is the reason in your case but it could also give you some direction to think of. I some time use this method (closing the outlook using task manager while it is still loading) to simulate this behavior and actually I have developed a tool which scans all the machines provided to it and checks if the add-In is disabled on a machine and if yes it changes the registry value to enable it.

Kapilg
No, it doesn't appear to be anything like that. Also, simply changing the LoadBehavior value back most of the time does not help - it will simply get reset back to 2 the next time Outlook starts.
Oliver Giesen
Were you really talking about the LoadBehavior entry, though? As far as I know the steps you describe would rather lead to an entry under the Resiliency key (aka "Disabled Items"), wouldn't it? The latter does not apply in my case.
Oliver Giesen
+3  A: 

My company has been putting up with what sounds like the same issue you are seeing for years. The plug-in we have is a VB6 COM add-in for Outlook 2003 and it’s deployed on several hundred machines that get cycled hundreds (if not thousands) of times a day. We go through the load and unload cycles a lot.

We get a fair bit of the general errors where the plug-in is loaded but not connected and we handle that in code. (Obviously not production quality)

Dim outlook As outlook.Application
Set outlook = CreateObject("Outlook.Application")
outlook.COMAddIns("MyFancyDancyPlugin").Connect = True

Rarely, but not so rare that it isn’t an annoyance, we see the plug-in reach a state where it is loaded and we can see it in “Tools>Options>Others>Advanced Options> Com Add-Ins”, but we just can’t connect to the thing. If you try to connect you don’t get an error it just switches back to disconnected. [The equivalent of switching back to a 2 in the registry key] The COM object as far as I can tell is never created. The item is not listed in the Disabled items.

We don’t actually have to redeploy to correct this error. Removing the object through the Com Add-Ins dialogue and then re-adding it there seems to correct the issue. This is still not an acceptable solution but it does get things back and running without a reinstall.

  • Windows XP Professional, up-to-date patch level
  • Outlook 2003 Professional, up-to-date patch level
  • varying versions of McAfee Virus Scan (though disabling it has no effect - see above)
  • Users are members of the local Administrators group

This seems to fit, we don't use McAfee but the virus scanner also doesn't interact with outlook or the com add-ins. We also don't use a copy protection app.

I'm sorry I can't be of more help, but I would love to root cause this.

Dan Blair
interesting. where do you place that `COMAddIns(...).Connect = True` code, though? a macro? a second addin?
Oliver Giesen
We have a secondary application that is dependent on Outlook. It uses the Outlook API to make sure the AddIn is registered and connected. (We have a couple flavors of the APP in VB6 and .Net C#)You could put the code in a second AddIn, it is a strategy for trying to make sure AddIn dependencies are satisfied but we've had no need to do that.
Dan Blair