Using a Separate Application Domain to Avoid Crashing

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Managed add-ins that implement the IDTExtensibility2 interface are loaded into the same default application domain. When an add-in in the application domain crashes, it can cause other add-ins in the same application domain to fail as well.

To work around this problem, you can create a shim for the add-in, so that the add-in can be loaded in its own application domain. A shim is an unmanaged dynamic link library written in C++. When you use a shim, you register the shim instead of the add-in. Outlook loads the shim, and the shim loads the add-in for which it was built. You must build and register a separate shim for each add-in. For more information about developing shims for managed add-ins, see Isolating Office Extensions with the COM Shim Wizard.

Another alternative to load your add-in into a separate application domain is to develop your add-in using Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System or Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System Second Edition. Add-ins developed by these versions of Visual Studio Tools for Office do not implement the IDTExtensibility2 interface but use the IStartup interface. They use a loader provided by Visual Studio Tools for Office, AddinLoader.dll, which acts like a generic shim. Outlook looks in the registry for add-ins created with Visual Studio Tools for Office. If Outlook finds add-ins created with Visual Studio Tools for Office, Outlook starts AddinLoader.dll, which then starts the Visual Studio Tools for Office run time and relays the application manifest to the Visual Studio Tools for Office run time. The Visual Studio Tools for Office run time then loads each Visual Studio Tools for Office add-in in a separate application domain. For more information about how Visual Studio 2005 Tools for Office loads an add-in, see Office Solutions Architecture Overview.