C#,WPF - 打开文件对话框不显示 [英] C#, WPF - OpenFileDialog does not appear

查看:159
本文介绍了C#,WPF - 打开文件对话框不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找向上和向下的网络和跨挺像我的一个问题,遗憾的是没有来,所以这里有云:

I have been searching up and down the web and unfortunately never came across an issue quite like mine, so here goes:

我的C#WPF应用程序将不会显示我没有OpenFileDialogs或SafeFileDialogs。

My C# WPF application won't show me no OpenFileDialogs or SafeFileDialogs.

private void btnBrowseNet_Click(object sender, RoutedEventArgs e)
    {
        OpenFileDialog ofd = new OpenFileDialog();
        ofd.CheckPathExists = true;
        ofd.Multiselect = false;
        ofd.Title = "Open Network Configuration Batch file...";
        ofd.ValidateNames = true;
        ofd.Filter = "Comma Seperated Value Files|*.csv";

        if (ofd.ShowDialog() == true)
        {
           //...
        }
    }

这确切code在一个场合不正是它是应该做的,几乎五分钟后,我可以点击按钮的所有我想要的,什么都不会发生,但将鼠标指针变成一个小忙指示器,然后什么。我可以通过方法步骤,或做这样的事情。

This exact code does in one occasion exactly what it is supposed to do and hardly five minutes later I can click the button all I want, nothing happens but the mouse pointer turning into a little busy-indicator and then nothing. I can step through the method or do something like this

bool? shown = ofd.ShowDialog();

但无论怎样,该对话框不会显示。当然,示出将在这种情况下,假。我昨天和右浪费一个半小时的搜索时我退出我又试了一下,突然它的工作的。有时工作,有时没有。但它似乎是具体项目,因为我可以粘贴在同一code到一个新的项目,它的工作原理是它应该做的事。此外,这是关于似乎腥该项目的唯一的事。一切按预期工作。

But no matter what, the dialog won't show. Of course, shown will be false in that case. I wasted one and a half hours searching yesterday and right when I quit I tried it again and all of a sudden it worked. Sometimes it works, sometimes it doesn't. But it seems to be project specific because I can paste the same code into a new project and it works like it is supposed to do. Also, that's the only thing about the project that seems fishy. Everything else works as intended.

有没有人就在这里经历过类似的东西,因此是什么在地球上我可以做一个想法?
任何帮助weould高度AP preciated。

Has anyone on here ever experienced something similar and thus an idea of what on earth I could do? Any help weould be highly appreciated.

推荐答案

有大量的可能的故障模式为打开文件对话框。使用一个暴露你的应用程序,只是有关的安装在计算机上的任何外壳扩展。其中许多是非常不稳定的,它不是有可能,如果它正常工作在WPF过程中的扩展笔者检查。

There are a large number of possible failure modes for OpenFileDialog. Using one exposes your app to just about any shell extension that's installed on your machine. Many of which can be very destabilizing, it isn't that likely that the extension author has checked if it works properly in a WPF process.

运行Sysinternals的自动运行程序解决这个问题。点击浏览器选项卡,并寻找有ShellEx的在他们的名字的组。取消选中不是由微软发布的任何东西。重新启动电脑,检查问题解决。

Tackle this problem by running SysInternals' AutoRuns utility. Click the Explorer tab and look for the groups that have "ShellEx" in their name. Uncheck anything that wasn't published by Microsoft. Reboot and check if the problem is solved.

这篇关于C#,WPF - 打开文件对话框不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆