I have the following simple scenario:
A DialogForm with a Button, the Button_click throws an exception.
A MainForm with a button and a Label, in the click I show a new instance of the DialogForm inside a Catch block.
If I run this setup in regular WinForms, I can catch the Exception as expected.
If I run this in WinMobile (I've tested on WM5 and WM6 Pro) I can see with a Debugger that the Catch block is entered but the Exception keeps propagating up and the App dies.
The code in MainForm looks like this:
try
{
using (DialogForm frm = new DialogForm())
{
DialogResult r = frm.ShowDialog();
label1.Text = r.ToString();
}
}
catch (Exception ex)
{
label1.Text = ex.Message;
}
Edit:
I investigated a little further, with a catch {} block around this code and around Application.Run() and the app still quits.
Apparently it is not a runaway Exception, that is caught and handled just fine. But after this operation it looks like the Application performs an unwanted Exit().
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…