-3

Several users of my VSTO add-ins report hangs that occur when a "Save as" dialog should be displayed. This happens with an Excel add-in as well as a Word add-in. Interestingly, both applications also tend to hang when invoking the "Save as" command on a document.

I am having a hard time to troubleshoot this because the entire application just freezes after

// using System.Windows.Forms;
SaveFileDialog dlg = new SaveFileDialog();
// lines to configure dlg left out
dlg.ShowDialog();

When attempting to close Excel or Word in this situation, a message box "Excel/Word can not be closed" appears, and people have to resort to the Task Manager to get rid of it.

The fact that both Excel and Word frequently hang on "Save as" is particularly disturbing, because I don't see how my add-ins interfere with the built-in "Save as" commands of these applications.

To make matters worse, the add-ins need not even be loaded. Deactivating them by unchecking the corresponding entry in "COM add-ins" and restarting the application does not solve the problem. I have to completely remove the add-ins to make sure "Save as" does not freeze the application.

This makes me think that it is not code in my add-ins that is the problem, but the mere presence of an (inactive) VSTO add-in that prevents a file dialog from appearing, thereby causing a hang.

The hangs do not always occur, and not on all machines. It's quite random.

How would I go about investigating this further? I have Visual Studio Professional 2013, but do not know how to find out why and where the Office application freeze.

bovender
  • 1,838
  • 15
  • 31
  • [C# MSDN SaveFileDialog](https://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog(v=vs.110).aspx) you need to show all relevant code.. if you are using COM Interop perhaps you are Marshal.Releasing the com objects properly.. please provide all relevant code – MethodMan Aug 31 '16 at 19:21
  • Could be the SaveDialog is behind another window. – Jim Hewitt Aug 31 '16 at 22:18
  • @JimHewitt Yeah, but I already tried and made the Excel/Word windows very small so that the dialog should be visible somewhere. And even if it was displayed out of screen for some reason, pressing ESC should close it if it has focus (and blocks Word/Excel) -- but ESC does not do anything. – bovender Sep 01 '16 at 04:24
  • @MethodMan I believe that this is indeed the relevant code. I have performed extensive tests with debugging, and the hang definitively occurs after calling `SaveFileDialog.ShowDialog()`. The add-ins are huge (e.g. https://github.com/bovender/xltoolbox). – bovender Sep 01 '16 at 04:26
  • I see people are disliking this question, that's fine. However, I have lots of users world wide and an increasing number are reporting this randomly occurring freeze. I need to get some pointers how to debug a frozen Office application. – bovender Sep 01 '16 at 04:27
  • 1
    sounds like you have an issue in your code.. if you have lots of users world wide then it appears that you have a underlying problem and what type of add in are you talking about.. once again showing 2 lines of code doesn't help anybody nor help is resolving your issue. I would say start with going through your code to make sure you are properly disposing of created objects in your code.. – MethodMan Sep 01 '16 at 14:05
  • Thanks for your time. Because the freeze also occurred during normal Open/Save operations and even if the add-in was not even loaded (but registered), I was inclined to think that this time, it was not my code's fault. I now found out it's a registry key that causes the freeze. – bovender Sep 03 '16 at 16:19

1 Answers1

2

Excel freezes on Open/Save As if a managed add-in is registered with a "Warmup" registry value, even if the add-in is not even loaded.

The "Warmup" registry value, when set to 1 in an add-in's registry key, was once supposed to cause Excel to load the VSTO runtime at startup, rather than when the first user interaction with the add-in occurred. Apparently, it was never implemented and has since been removed from Microsoft's online documentation of the registry entries for VSTO add-ins.

Once I removed the "Warmup" value from my add-in's registry key, Excel's Open/Save As dialogs no longer froze, nor did the add-in's own SaveFileDialog.ShowDialog() calls. I don't know why this is, but evidently, the "Warmup" value does do something.

I was able to reproduce this with a dummy add-in that does not do anything. If that dummy add-in is registered in HKCU\Software\Microsoft\Excel\Addins without the "Warmup" DWORD, Excel works just fine. As soon as I add the DWORD with a value of 1, Excel freezes when I click Open or Save As -- again, the dummy add-in does not do anything at all.

So, if people get here wondering why their Office application freezes after installation of a VSTO add-in, I'd suggest to remove the "Warmup" value from the registry rather than spending hours debugging their code (as I did before I found out about "Warmup").

Feedback from my users is positive.

Community
  • 1
  • 1
bovender
  • 1,838
  • 15
  • 31