首页 > 解决方案 > OpenFileDialog 未返回到代码 Windows 窗体

问题描述

我一直在 Windows Froms 中开发一个应用程序来选择多个 Visual Studio sln 文件并将它们添加到列表中。该应用程序在两台机器上运行良好,但在其他两台机器上却卡住了。如果问题出在系统中的路径上,我们进行了一些研究,但所有路径都相同。最后,我们决定在不起作用的机器上“再次”开发应用程序,我们注意到当我们打开文件对话框时出现问题,它永远不会返回代码。

private void AddService_Click(object sender, EventArgs e)
    {
        OpenFileDialog fileDial = new OpenFileDialog();
        fileDial.InitialDirectory = textPath.Text;
        fileDial.Filter = "Sln(*.sln)|*.sln";
        fileDial.FilterIndex = 1;
        fileDial.Multiselect = true;

        if (fileDial.ShowDialog() == DialogResult.OK)//Never returns to test the condition.
        { //Add to list here} 
    }

首先我们认为是内存问题,但系统中的内存使用量非常低,运行的应用程序的内存使用量为 26.7 MB。我们的 app.config 文件是这样的:

<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

我们的开发和目标系统是 Windows Server 2012。应用程序运行良好的系统是两个 Windows Server 2012,它们是应用程序无法运行的机器的克隆,使用 sysprep 制作。

标签: c#windowswindows-forms-designeropenfiledialog

解决方案


推荐阅读