【发布时间】:2020-03-05 01:04:44
【问题描述】:
大多数时候,OpenFileDialog 显示没有问题,但在极少数情况下,显示它会导致应用程序无限期挂起,直到进程结束。
OpenFileDialog 定义如下:
var dialog = new OpenFileDialog
{
ValidateNames = false,
CheckFileExists = false,
CheckPathExists = true,
FileName = "This Folder",
};
if (dialog.ShowDialog() == DialogResult.OK)
{
//logic here
}
对类似问题的回答表明该问题可能与我的应用程序正在使用的 DLL 有关。
成功运行的可能相关调试输出如下:
每当程序启动时:
...
'Program Name.exe' (Win32): Loaded 'C:\Windows\SysWOW64\iertutil.dll'.
'Program Name.exe' (Win32): Loaded 'C:\Windows\SysWOW64\propsys.dll'.
Exception thrown at 0x74EC3572 in Program Name.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x00B3D034.
Exception thrown at 0x74EC3572 in Program Name.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
Exception thrown at 0x74EC3572 in Program Name.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
'Program Name.exe' (CLR v4.0.30319: Program Name.exe): Loaded 'Microsoft.GeneratedCode'.
'Program Name.exe' (Win32): Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\Microsoft.V9921e851#\10e86f631668518a182dfda3901d1848\Microsoft.VisualBasic.ni.dll'.
...
OpenFileDialog 第一次在程序运行中显示:
...
'Program Name.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sxs.dll'.
mincore\com\oleaut32\dispatch\ups.cpp(2125)\OLEAUT32.dll!77444221: (caller: 77444318) ReturnHr(1) tid(7cb0) 8002801D Library not registered.
'Program Name.exe' (Win32): Loaded 'C:\Windows\SysWOW64\StructuredQuery.dll'.
...
'Program Name.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp140.dll'.
'Program Name.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140.dll'.
Exception thrown at 0x74EC3572 in Program Name.exe: Microsoft C++ exception: Mso::RegistryException at memory location 0x0B15C968.
Exception thrown at 0x74EC3572 in Program Name.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
'Program Name.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msi.dll'.
...
由于打开 OpenFileDialog 很少会导致应用程序挂起,因此我没有任何此类运行的调试输出。
当我在 CLI 模式下运行应用程序时,没有出现上述异常。
我已尝试研究上述异常消息,但这并没有让我找到解决方案。
您知道导致此问题的原因吗?
您对我如何继续调试问题有什么建议吗?
【问题讨论】:
-
你不能调试它,它不是你的代码。你需要修好你的机器。使用 SysInternals 的 AutoRuns 实用程序并首先禁用所有没有 Microsoft 版权的 shell 扩展。
标签: c# .net dll openfiledialog