OpenFileDialog 导致 WPF 应用程序崩溃 [英] OpenFileDialog causes WPF app to crash

查看:89
本文介绍了OpenFileDialog 导致 WPF 应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 WPF 应用程序中,我使用 OpenFileDialog 选择图像并将其加载到应用程序中,这按预期工作正常.

In my WPF Application I used OpenFileDialog to select an image and load it to app, this works fine as expected.

但是如果我从闪存驱动器运行相同的应用程序,图像会在 UI 冻结后加载,对 UI 的任何点击都会使应用程序崩溃.

But if I run same app from a flash drive, image loades after that UI freezes, any clicks on UI makes app to crash.

我也有应用程序的管理员 manifest.

I have admin manifest to app also.

推荐答案

Here 在这种情况下 OpenFileDialog 将导致应用程序挂起和崩溃.

Here In this case OpenFileDialog will cause the app to hang and crash.

因此将 OpenFileDialog 移至新线程.一切正常.

So moved OpenFileDialog to a new thread. And everything works fine.

这篇关于OpenFileDialog 导致 WPF 应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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