SaveFileDialog silently crashes WinForms app on WindowsXP

人走茶凉 提交于 2019-12-02 17:26:35

问题


I'm developing WinForms app using C#, .NET 4.0, and DevExpress components.

On Windows 7 everything is working just fine.

On Windows XP SP3, few seconds after SaveFileDialog is shown and closed, application will silently exit.

There is no unhandled exception, Application exit event will not fire, I'm only getting message in the Visual Studio Output window:

The program '[3164] MyApp.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).

Code that is causing this issue is very simple:

saveFileDialog1.ShowDialog();

Do you have any ideas why is this happening? How can I troubleshoot and fix this?


回答1:


Enable unmanaged debugging in the project properties window. And ensure that Visual Studio is set to break on all exceptions (check the "Throw" option in the Debug\Exceptions menu).

Then run your application again. VS should now break on the exception - it should be a shell extension or file handler that's causing your app to fail.




回答2:


You can try to call your SaveFileDialog in a new Thread, and tell us if it works.

You can have A first chance exception of type 'System.Threading.ThreadAbortException' occurred in System.Windows.Forms.dll, and that will crash your application.

I think this happens because the current Thread is not suitable for running a SaveFileDialog.

Advice: review if you're dealing with threads (in order to correct some), and try to launch a new Thread to start the desired file dialog.



来源:https://stackoverflow.com/questions/7176039/savefiledialog-silently-crashes-winforms-app-on-windowsxp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!