I'm trying to do this:
I'm creating another form, which in it's FormClosed method throws an exception, that should be caught by the main form.
Main Form:
try
{
frmOptions frm = new frmOptions();
frm.ShowDialog();
}
catch(Exception)
{
MessageBox.Show("Exception caught.");
}
frmOptions:
private void frmOptions_FormClosed(object sender, FormClosedEventArgs e)
{
throw new Exception();
}
The debugger stops on the exception with this message:
Exception was unhandled by user code
Why? I'm catching the exception in the owner of the object that created it. Anybody has an idea?