VSTO: Understanding
Application–Level Add–Ins Architecture
The main design considerations of Office Application-Level
Add-In Architecture are following:
·
Each add-in is loaded in new application domain so as to isolate
it from main app and other add-ins. Thus if the add-in hangs whole app doesn’t
crashes.
·
Security and Permission level checks performed on add-ins.
·
Clean shutdown of application and loaded add-ins.
The main components which take part in functioning of
Application-Level Add-Ins are following:
Architecture Components
Runtime Loader
The component is named VSTOEE.dll and is responsible
for loading the correct version of VSTO runtime when a document-level
customization is opened or add-in is started.
Solution Loader
It is named VSTOLoader.dll. This is responsible for
loading the VSTO application. It also creates a new Application Domain for each
add-in and performs security checks on VSTO application.
Registry Entry
This is where the Office application discovers the add-ins
installed and to be loaded.
Applications in the 2007 Microsoft Office system look for
the Manifest entry under the key
HKEY_CURRENT_USER\Software\Microsoft\Office\application name\Addins\add-in ID
(or, for Visio, HKEY_CURRENT_USER\Software\Microsoft\Visio\Addins\add-in ID).
The Manifest entry specifies the full path of the
deployment manifest.
Deployment Manifest and
Application Manifest
The list of Deployment manifest indicates the add-ins
installed. Each deployment manifest points to the correct version of an
application manifest which in turn points to assembly paths and entry points.
Add-In Loading Process
1. The
Office Client application checks the registry installed add-ins.
2. It
loads Runtime Loader which in turn loads Solution Loader.
3. Solution
Loader loads the .NET Runtime and managed portion of VSTO Runtime.
4. Latest
versions of Deployment and Application manifests are downloaded. Once security
checks are passed, latest add-in assemblies are downloaded.
5. New
application domains are created for each add-in and add-ins are loaded into
that app domain.
6. Various
entry point methods of Add-in are called before finally calling
ThisAddIn_Startup method which is default event handler for Startup event.