How to troubleshoot a VSTO addin that does not load?
Asked Answered
S

7

82

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?

Subtemperate answered 12/1, 2011 at 12:27 Comment(6)
This question is about VSTO for an Outlook-Add-In, but the problem is a general Office problem. The question and its answers helped me with an Excel 2010 Add-In.Dowager
+1 for introducing me to the VSTO_SUPPRESSDISPLAYALERTS environment variableChou
@Subtemperate - thanks for asking this question, I added most of the other solutions that trip people up. The Disabled one is easy to fix unless it happens on citrix...Goatee
Please also see this for Outlook 2007 changing LoadBehavior to 0: #7691872Compilation
Did you check the manifest file is present at proper location? Also check if the registry entry of that Add-in is present or not in both branches, HKLM & HKCU.Tarmac
If you are interested please commit for this : stackoverflow.com/documentation/outlook-addin/commitAlodi
Y
54

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.

Yoder answered 13/1, 2011 at 17:59 Comment(6)
That's exactly the problem: I check the box in the COM-AddIns screen, click OK, re-enter the COM-AddIns screen and the box is unchecked again. No error message whatsoever appears.Subtemperate
I mean checking the disabled addin queue (not your unchecked add-in). In the add-in type drop down its the last item in the list. Its like purgatory for potentially bad add-ins.Yoder
+1, you're right, of course. Sorry for reading your answer wrong the first time (the downvote is not from me, btw). I'll mark yours as the answer, but I'll keep my answer here as well, since it's bit more verbose.Subtemperate
It appears if the plugin crashes it will be added to the disabled plugins. I'm not sure if the plugin crashed too many times or Outlook determined that they type of crash was severe enough, anyways you have to remove it from there first. Trying to enable it otherwise won't work.Bandsman
If you're still having issues try wrapping everything in the app start in a try catch.Bandsman
i've removed mine completely to get a clear install from a new solution. now after starting outlook with F5 i don't see it in add-ins or disabled add-ins listMedicament
S
59

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

Subtemperate answered 14/1, 2011 at 9:7 Comment(1)
Great. Thank you for the reference. I add that for Microsoft Office 2003 applications list of disabled addins is placed in "Help-About" menu.Edmondson
Y
54

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.

Yoder answered 13/1, 2011 at 17:59 Comment(6)
That's exactly the problem: I check the box in the COM-AddIns screen, click OK, re-enter the COM-AddIns screen and the box is unchecked again. No error message whatsoever appears.Subtemperate
I mean checking the disabled addin queue (not your unchecked add-in). In the add-in type drop down its the last item in the list. Its like purgatory for potentially bad add-ins.Yoder
+1, you're right, of course. Sorry for reading your answer wrong the first time (the downvote is not from me, btw). I'll mark yours as the answer, but I'll keep my answer here as well, since it's bit more verbose.Subtemperate
It appears if the plugin crashes it will be added to the disabled plugins. I'm not sure if the plugin crashed too many times or Outlook determined that they type of crash was severe enough, anyways you have to remove it from there first. Trying to enable it otherwise won't work.Bandsman
If you're still having issues try wrapping everything in the app start in a try catch.Bandsman
i've removed mine completely to get a clear install from a new solution. now after starting outlook with F5 i don't see it in add-ins or disabled add-ins listMedicament
G
51

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.

To set VSTO logging and alerts 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).

Goatee answered 5/2, 2013 at 0:34 Comment(4)
4). The Add-In was disabled. -> that did it for me!Neuron
Manage needs to be set to Disabled Items was the kicker for me. thx!Nubbly
Brilliant answer. Once I discovered the Env. Variables to stop the suppression of errors, I could see that my Add-In was crashing missing ''SQLite.Interop.dll'. Many, many thanks.Selfimmolation
Almost 10 years later, this answer saved my day! Setting those two environment variables got me exactly to the problem. Thank you!Nanji
R
8

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

Racehorse answered 23/5, 2013 at 11:40 Comment(4)
After trying out all sorts of things, this tool worked for me. Turns out that the addin was being loaded but some other dependency (a dll) was not being loaded because "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded". AddinSpy helped me get that error message.Oxidate
It's really disappointing that's a dead link. I think that would have helped me solve my problem.Sugared
You might want to search for a download location. Here's a page to see what it looked like: msdn.microsoft.com/en-us/library/cc984533%28v=office.12%29.aspxShigella
If you don't mind building it yourself, the (unofficial) source for AddInSpy is available from GitHub: github.com/NetOfficeFw/AddInSpyDormer
D
2

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/

Downs answered 11/10, 2016 at 20:31 Comment(1)
This was the issue for me too, in the case of running automation tests and opening and closing Excel each time per test. One of the tests was leaving a rogue Excel.exe behind.Proustite
S
1

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.

Sweatband answered 26/10, 2016 at 3:11 Comment(0)
P
0

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] Could not load file or assembly or one of its dependencies

Phantasm answered 7/5, 2016 at 21:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.