VSTO Add-In : Load Error [Outlook and other Office Applications]

A common issue faced by VSTO Add-in developers is the failure to load the add-in when your Office application starts. For example, the following message appears in COM Add-in window of Outlook 2003 if it is unable to load your add-in:

“Not Loaded. A runtime error occurred during the loading of the COM Add-in”

There can be many reasons for this behavior and requires your step by step verification of each one. Note that the message descriptions given below are specific for Outlook 2003 and Outlook 2007 and may vary for other office applications.

1. Enable the Add-in (if it is found under disabled items)

Outlook 2003:

  • Go to Help –> About Microsoft Office
  • Click on “Disabled Items”
  • Select your add-in (if found there) and click enable
  • Close and start Outlook

Outlook 2007:

Use the following steps to access Disabled items:

  • Go to Help—> Disabled Items

OR

  • On the Tools menu, click Trust Center.
  • In the Navigation Pane, click Add-ins.
  • In the Manage list, select Disabled Items, and then click Go.

2. Enable the Add-in from  COM Add-in Window

Outlook 2003:

  • Go to Tools –> Options –> Others –> Advanced Options –> COM Add-ins
  • Select and Check your add-in (if found there as unchecked) and click OK
  • Your outlook plug-in should load now, if not go back to COM Add-ins window and see if there are any error messages.

Outlook 2007:

Use the following steps to access Disabled items:

  • On the Tools menu, click Trust Center.
  • In the Navigation Pane, click Add-ins.
  • In the Manage list, select COM Add-ins, and then click Go.
  • Select and Check your add-in (if found there as unchecked) and click OK

3. Check registry settings

  • Go to : HKEY_LOCAL_MACHINE\Software\Microsoft\Office\Outlook\Addins\<AddIn Name> (Or HKCU equivalent)
  • Check the loadbehavior key value. If it is set to 2, change to 3 and start your Outlook
  • If the Add-in does not load, go back to registry and check the loadbehavior value. You may notice that the value is changed back to 2 (indicating the problem while loading your plug-in) and we should go to next steps.

4. Check CAS (Code Access Security) permissions for the code group

Your Add-in assemblies code group should be given “FullTrust” permission. You can verify the current permission levels using one of the following.

  • CASPOL.EXE : Use caspol tool to query the code groups and permission levels
  • Use .NET Framework Configuration Tool (mscorcfg.msc)

If FullTrust permissions are not given, use caspol.exe to grant FullTrust to the add-in assemblies

Example: <From Visual Studio Command Prompt>

caspol -u -ag All_Code –url  “C:\<FolderName>\<FolderName>\*” FullTrust -n "<Name>" –d "<Description>"

More details on CAS is out of scope for this post. You can refer this for detailed instructions: How to: Grant Permissions to Folders and Assemblies

5. Check Primary Interop Assemblies (PIA) are installed correct

Verify whether Primary Interop Assemblies [for Office 2003 or Office 2007 depending upon your version of MS Office] installed correctly on your machine. To check this, go to GAC (%systemroot%\assembly) and look for assemblies named Microsoft.Office.Interop.*  and their versions.

If not installed, get it downloaded from the following URLs:

6. Add Custom Logging

Place the code in the Startup event to log exception details to  System Event Log which can give you if the exceptions are occurred during the load event.

<To be updated>

The above steps will help to identify/fix the load error. If you do not find the solution for your error get more help from this Microsoft Support Link to troubleshoot.

Advertisements

One thought on “VSTO Add-In : Load Error [Outlook and other Office Applications]

  1. I think the admin of this site is genuinely working hard in favor of his
    web site, because here every information is quality
    based information.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s