OpenFileDialog 在 Windows XP 下崩溃,但在 Windows 7 下不会崩溃

发布于 2024-11-01 00:59:00 字数 844 浏览 2 评论 0原文

我遇到了一个以前从未见过的奇怪问题。我可以在 Windows 7 中打开 OpenFileDialog ,没有任何问题。但是,当我在 Windows XP 上尝试我的应用程序时,调用 OpenFileDialog.ShowDialog() 会立即导致应用程序崩溃。它就这样消失了!从调试器运行时,我没有收到任何未处理的异常。如果我将代码包装在 try/catch 块中,则不会捕获任何内容。我还检查了 Debug -> 中所有抛出的异常异常,但什么也没有弹出。我将尝试下面答案中的一些其他建议,然后进行报告。

有谁知道如何解决这个问题?我找到了 发布类似的内容,但问题相反。我会尝试调整桌面设置,看看是否与此相关,但我对此表示怀疑。

编辑 - 作为健全性检查,我编写了一个测试 WPF 应用程序,该应用程序直接通过主窗口显示 OpenFileDialog 以及可以由主窗口显示的另一个 Window 。在 Windows XP 下完全可以正常工作。所以现在我真的很困惑。我已经验证我没有做一些愚蠢的事情,比如尝试从工作线程显示对话框。 OpenFileDialog 会短暂显示,然后随应用程序一起消失。

编辑——我将尝试在另一台 XP 计算机上重现此问题。现在,我将尝试 Windows XP 模式,看看会发生什么。

I've got a strange problem I haven't seen before. I can open an OpenFileDialog in Windows 7 without any problems. However, when I try my app on Windows XP, calling OpenFileDialog.ShowDialog() immediately crashes the application. It just vanishes! When running from the debugger, I don't get any unhandled exceptions. If I wrap the code in a try/catch block, nothing gets caught. I have also checked all thrown exceptions in Debug -> Exceptions, but nothing pops up. I'll try some of the other suggestions in the answers below and will report back.

Does anyone know how to resolve this problem? I found a post about something similar, but it was the opposite problem. I'll try tweaking the desktop settings to see if it's related to that, but I am dubious.

EDIT -- as a sanity check, I wrote a test WPF application that displays an OpenFileDialog directly via the main window as well as another Window that can be displayed by the main window. It totally works fine under Windows XP. So now I'm really confused. I have verified that I'm not doing something stupid like trying to display the dialog from a worker thread. The OpenFileDialog displays briefly, then disappears along with the application.

EDIT -- I'm going to try to reproduce this problem on another XP computer. For now, I'll try Windows XP mode and we'll see what happens.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

初懵 2024-11-08 00:59:00

当我打开 OpenFileDialog 时 DLL 崩溃时,我遇到了类似的错误。事实证明,OpenFileDialog 更改了工作目录,因此我的 dll 尝试写入不存在的相关文件。

I got a similar error when a DLL crashes when I open a OpenFileDialog. It turned out that OpenFileDialog changed the working directory so my dll tried to write to a relative file that did not exist.

尛丟丟 2024-11-08 00:59:00

您在输出中看到任何“第一次机会”异常吗?事件日志中有任何条目吗?您使用的默认路径是否存在于 XP 计算机上?

尝试向应用程序域的 UnhandledException 添加处理程序。

当您使用全新的、库存的 FileOpenDialog 而不进行任何调整时,是否会发生同样的情况?一个全新的应用程序除了显示文件打开对话框之外什么都不做,怎么样?

Do you see any "First Chance" exceptions in the Output? Any entries in the event log? Does the default path you're using exist on the XP machine?

Try adding a handler to the App Domain's UnhandledException

Does the same happen when you use a brand new, stock FileOpenDialog without any tweaks? What about from a brand new app which does nothing but show a file open dialog?

瀟灑尐姊 2024-11-08 00:59:00

请参阅 Galet 的帖子


我无法告诉你问题到底是什么,但您可以通过以下操作来了解到底发生了什么。我假设你使用的是VS2008或2005。

1.切换到发布模式
2.转到 Debug\Exceptions,并标记所有“抛出”异常,如下所示: http:// vvcap.net/db/JbWS_tzy2IpBoI7R7amm.htp
3.在调试器中运行可执行文件,忽略VS中没有调试信息的警告
看起来确实在执行过程中的某个时间抛出了 win32 异常,但是这样或那样,您将从调试器收到一条或多条消息,解释发生了哪种异常以及发生在何处。在大多数情况下,这些消息清楚地表明到底出了什么问题

编辑:我忘记提到的一件事是还必须打开非托管调试,例如此处(当您直接从 IDE 启动程序时)或此处(当您附加到运行过程)
link|edit|flag 于 2009 年 4 月 12 日 22:32 编辑 于

2009 年 4 月 10 日 19:01 回答
加莱茨
1,2201924

See Galet's post


I cannot tell you what exactly the problem is, but here's what you could do to get a clue what's really happening. I assume you're using VS2008 or 2005.

1.Switch to release mode
2.Go to Debug\Exceptions, and mark all "Thrown" exceptions, like illustrated here: http://vvcap.net/db/JbWS_tzy2IpBoI7R7amm.htp
3.Run executable in debugger, ignore the warnings from VS that there's no debug info
It does seem that there's a win32 exception thrown some time during execution, but this way or another, you will get one or more messages from debugger explaining what kind of exception happened and where. In most cases those messages make it pretty clear what exactly went wrong

EDIT: One thing I forgot to mention is that unmanaged debugging must also be turned on, such like here (when you start program directly from IDE) or here (when you attach to running process)
link|edit|flag edited Apr 12 '09 at 22:32

answered Apr 10 '09 at 19:01
galets
1,2201924

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文