SaveFileDialog silently crashes WinForms app on Wi

2019-03-05 09:20发布

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?

2条回答
我命由我不由天
2楼-- · 2019-03-05 10:13

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.

查看更多
干净又极端
3楼-- · 2019-03-05 10:25

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.

查看更多
登录 后发表回答