How to troubleshoot a VSTO addin that does not load?

.NetVstoOutlook Addin

.Net Problem Overview


My VSTO Outlook Add-in suddenly stopped working on one customer machine (it does not load, no error message) and I'm stuck with troubleshooting. The machine is Windows 7 x86, Outlook 2007. The add-in is written with Visual Studio 2008 and uses VSTO 2005 with the 2003 PIAs (because we need to support Outlook 2003 as well). It works perfectly fine on other machines.

Here's what I tried to get useful troubleshooting output:

Nothing. The add-in just won't load without giving any indication of the reason. I've also checked the "usual suspects" (CAS policy, PIAs installed, LoadBehavior in the registry, reinstalling VSTO and the add-in).

Some other observations:

  • LoadBehavior in the registry stays at 3.
  • The add-in shows up as "disabled" in Outlook. Checking its checkbox in "COM add-ins" just does nothing (no error, checkbox is cleared again when entering the form a second time).
  • It works perfectly fine on other customer machines, and it worked perfectly fine on this machine. (No, the customer cannot tell me what changed on his machine.)
  • I have a Trace.WriteLine message at the very top of my code (first line in the ThisAddIn_Startup handler), which is not reached (I checked with DebugView). Thus, the reason for not loading is not an exception in my add-in but rather a failure of VSTO to load the add-in or of Outlook to load VSTO.

Instead of more random debugging ("try this...", "try that..."), I'd really like to force Outlook and/or VSTO to tell me what's wrong, i.e. to give me a useful error message instead of just doing nothing when trying to enable the add-in. Any ideas?

.Net Solutions


Solution 1 - .Net

Here's a bit more detail on RobertG5's solution (too long for a comment):

The problem was that the add-in had been hard disabled by Outlook. As I've learned, that's something different than the "usual" not-loading scenario. The key to realizing this was to notice that the add-in did not show up under Inactive Application Add-Ins, but rather under Disabled Application Add-Ins. That makes a difference: In the latter case, just going to the COM-AddIn screen and ticking the check box just does nothing. (I guess a nice message box "You cannot load this add-in because it has been hard-disabled" would be too much to ask... sigh.)

So, how do I re-enable a hard disabled add-in?

  1. In the Manage box, change COM Add-ins to Disabled Add-ins, and then click Go.
  2. Select the add-in and click Enable. Click Close.

OK, now the add-in can be loaded again:

  1. In the Manage box, change Disabled Add-ins to COM Add-ins, and then click Go.
  2. select the check box next to the disabled add-in. Click OK.

Reference: http://msdn.microsoft.com/en-us/library/ms268871.aspx

Solution 2 - .Net

Did you try enabling the add-in again? It won't run after its in the disabled queue. After you re-enable it from the disabled add-in screen, you can then check the box in the COM-AddIn screen to have it load which then should prompt you more detail since you set the VSTO_SUPPRESSDISPLAYALERTS variable about what may have happened in the first place.

Solution 3 - .Net

I know this is old but for various reasons I've recently been troubleshooting Office Add-Ins that dont load.

Its chewed up heaps of time so I thought I'd share, so if your add-in wont load or its not visible or etc please try these solutions.

1. The Add-In is not loaded.

Not loaded. A runtime error occurred during the loading of the COM Add-In.

enter image description here

The problem is due to missing .Net framework 3.5 or 4.0.

Note: If the Office version is 64-bit (x64), I only need .Net 4.0. However, if the office version is 32-bit (x86), I get the error after installing .Net 4.0, as well. Following this article, I installed .Net 3.5, and then it worked on the x86 Office!

Plus need to install VSTO Runtime 3.0 form here.

2. The Add-In is not loaded.

Double check you have spelt the registry keys correctly. Occassionally I type Behaviour but in American spelling is Behavior, so double check "LoadBehavior"

enter image description here

Also make sure "LoadBehavior" is 3, for a list of values see http://msdn.microsoft.com/en-us/library/vstudio/bb386106.aspx#LoadBehavior

3. The Add-In is not visible.

You can make the add-In visible by going to Excel > File > Options > Add-Ins > select the Manage dropdownlist and set it to COM Add-Ins > Click GO. In the COM Add-Ins dialog make sure that Add-In is ticked.

4. The Add-In was disabled.

Alternatively the add-in may be hidden because it has been disabled. You can enable the add-In by going to Excel > File > Options > Add-Ins > select the Manage dropdownlist and set it Disabled and click GO. Select the Add-In that has been disabled and click Enable.

enter image description here

5. The ExcelDNA User Defined Formula is not rendering correctly

Instead of seeing the cell value you see: #NAME?

Set the following registry key:

HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\options\OPEN:

With the correct value:

/R "C:\Program Files\XYZ\XYZ Addin\ExcelDNA.XYZAddIn.xll"

6. Excel HANGS after showing a messagebox

Turn back on the application settings:

xlApp.ScreenUpdating = true;
xlApp.DisplayAlerts = true;
xlApp.Calculation = XlCalculation.xlCalculationAutomatic;
xlApp.UserControl = true;
xlApp.EnableEvents = true;

7. Further troubleshooting

Enable your VSTO log file by adding the following on your system environment variables:

NAME: VSTO_LOGALERTS
VALUE: 1

There might be an exception error that is why your add-in is not loading.

You can check this source for more info on VSTO logging and alerts, but in essence you change two environment variable values depending on what you need to do:

> Displaying VSTO Alert Prompts > > To display each error in a message box, set the > VSTO_SUPPRESSDISPLAYALERTS variable to 0 (zero). You can suppress the > messages by setting the variable to 1 (one). > > Logging VSTO Alerts to a Log file > > To write the errors to a log file, set the VSTO_LOGALERTS variable > to 1 (one). > > Visual Studio Tools for Office creates the log file in the folder that > contains the application manifest. The default name is .manifest.log. > To stop logging errors, set the variable to 0 (zero).

Solution 4 - .Net

I would suggest using a Microsoft tool to diagnose add-in issues called AddinSpy.

Solution 5 - .Net

Funny for me, I tried a reboot. Fixed it for me. However, The reason it fixed it for me, is I had a rogue Excel.exe running hidden. The addin was not starting due to this other excel application running (I was migrating an MSAccess application to VSTO), so Access had an automation app open hidden.

In short, if your addin is not starting up, quick check for is to just make sure there's no other Excel applications running. This of course only applies when you're trying to get a brand new one installed/up and running.

(I used this link) https://www.add-in-express.com/creating-addins-blog/2012/11/13/wix-installation-vsto-office-addin/

Solution 6 - .Net

There is also another possibility here as to why you are getting no feedback even with the Environment Variables mentioned above being set. I found if you were getting this error after an install (not a previous VSTO that had been working) you should also double check the registry and the "Manifest" entry if you have one.

While Jeremy Thompson points out the Registry in his Second bullet point he does not show the Manifest entry that could be part of your registry settings. If your Manifest entry is not pointing to the correct path and file it will show up in the Add-Ins listing with an entry of "Not Loaded".

Here we see a bad entry that just points to the VSTO file only, no path. enter image description here

This will cause your AddIn to look like it loaded with errors, but no errors are popping up and appearing for you and making things frustrating. So it will look like this below, notice the location entry below also does not show the path. enter image description here

Correct the entry by putting in the proper path along with the file name and it will fix this.

The lack of errors I assume comes from the fact that you were pointing at nothing initially, so it lists the AddIn because it is in the registry, even though there is nothing to load.

Solution 7 - .Net

Eventually I coaxed Word to tell me:

    Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateStartupObjectException: 
Could not create an instance of startup object blaghblagh ---> 
System.TypeInitializationException: The type initializer for 'foo' threw an exception. ---> 
System.IO.FileNotFoundException: Could not load file or assembly 'blah' or one of its dependencies. 
The system cannot find the file specified.

After that, thanks to [1], FusLogvw quickly solved the problem for me.

[1] https://stackoverflow.com/questions/4469929/could-not-load-file-or-assembly-or-one-of-its-dependencies

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHeinziView Question on Stackoverflow
Solution 1 - .NetHeinziView Answer on Stackoverflow
Solution 2 - .NetGardnerView Answer on Stackoverflow
Solution 3 - .NetJeremy ThompsonView Answer on Stackoverflow
Solution 4 - .NetCédric GuillemetteView Answer on Stackoverflow
Solution 5 - .NetrealPTView Answer on Stackoverflow
Solution 6 - .NetBrian HView Answer on Stackoverflow
Solution 7 - .NetJasonPlutextView Answer on Stackoverflow