繁体   English   中英

显示 OpenFileDialog 有时会导致应用程序挂起

[英]Showing an OpenFileDialog occasionally causes the application to hang

大多数时候,OpenFileDialog 显示没有问题,但在极少数情况下,显示它会导致应用程序无限期挂起,直到进程结束。

OpenFileDialog 定义如下:

        var dialog = new OpenFileDialog
        {
            ValidateNames = false,
            CheckFileExists = false,
            CheckPathExists = true,
            FileName = "This Folder",
        };
        if (dialog.ShowDialog() == DialogResult.OK)
        {
            //logic here
        }

对类似问题的回答表明该问题可能与我的应用程序正在使用的 DLL 有关。

成功运行的可能相关调试 output 如下:

每当启动程序时:

...
'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 很少会导致应用程序挂起,因此我没有针对此类运行的任何调试 output。

当我在其 CLI 模式下运行应用程序时,不存在上述异常。

我曾尝试研究上述异常消息,但这并没有让我找到解决方案。

你知道什么可能导致这个问题吗?

您对我如何继续调试问题有什么建议吗?

这也发生在我身上。 发生这种情况是因为调用 openFileDialog 的表单是在不同的线程中创建的,但我仍然不知道它为什么会发生。 一种可能的解决方法是:

    var dialog = new OpenFileDialog
    {
        ValidateNames = false,
        CheckFileExists = false,
        CheckPathExists = true,
        FileName = "This Folder",
    };
    this.Hide();
    if (dialog.ShowDialog() == DialogResult.OK)
    {
        //logic here
    }
    this.Show();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM