如何调试挂起SaveFileDialog [英] How to debug hanging SaveFileDialog
问题描述
当显示另存为对话框时,我的VSTO加载项报表的几个用户挂起。这种情况发生在Excel加载项以及Word加载项中。有趣的是,当在文档上调用另存为命令时,两个应用程序也会挂起。
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();
在这种情况下尝试关闭Excel或Word时,会出现一个消息框Excel / Word不能关闭出现,人们不得不诉诸于任务管理器来摆脱它。
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.
Excel和Word经常挂起另存为的事实特别令人不安,因为我看不到我的加载项如何干扰这些应用程序的内置另存为命令。
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.
更糟糕的是,添加 - 甚至不需要加载。通过取消选中COM加载项中的相应条目并重新启动应用程序来停用它们不能解决问题。我必须完全删除加载项,以确保另存为不冻结应用程序。
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.
这让我觉得它不是我的add-这是问题,但只是存在(非活动)VSTO加载项,从而阻止文件对话框出现,从而导致挂起。
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.
我将如何进一步调查?我有Visual Studio Professional 2013,但不知道如何找出Office应用程序冻结的原因和位置。
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.
推荐答案
Excel冻结打开/保存就好像一个托管加载项注册了一个预热注册表值,即使加载项没有加载。
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.
预热 注册表值在加载项的注册表项中设置为1时,曾经被认为导致Excel在启动时加载VSTO运行时,而不是当第一个用户与加载项的交互发生时。显然,它从未实现,并已从Microsoft的在线 VSTO加载项的注册表项文档。
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.
一旦我从加载项的注册表项中删除了预热值,Excel的打开/另存为对话框就不再冻结了,加载项自己也不会保存 SaveFileDialog.ShowDialog()
电话。我不知道为什么会这样,但显然地,热身的价值确实会做某些。
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.
我能够再现这个一个没有做任何事情的虚拟加载项。如果这个虚拟加载项在 HKCU\Software\Microsoft\Excel\Addins
中注册,而没有预热 DWORD
,Excel工作正常。当我添加 DWORD
,值为 1
时,当我点击打开或另存为时,Excel会冻结 - 再一次,虚拟加载项根本就没有做任何事情。
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.
所以,如果人们在这里想知道为什么他们的Office应用程序在安装VSTO加载项后冻结,我建议从注册表中删除预热值,而不是花费几个小时调试代码(就像我之前发现的热身)。
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.
这篇关于如何调试挂起SaveFileDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!