Untrapped Error

Normally an untrapped error in Visual Basic 6.0 and earlier would result in a quick MessageBox and then our process shutting down. Windows Forms however have injected a top-level error catch between the CLR and our code. Whether or not you see their dialog depends upon three things:
1) == there an active debugger?
2) Do you have your own exception handler in place?
3) Have you turned JIT debugging on (set to true) in your App's config file.?
if an untrapped error occurs and you answered no to the
above questions, then you will see the Windows Forms dialgo
which gives the user a chance to Continue or Quit.
To see thier handler, you need to run the compiled code.



private void cmdUntrapped_Click(object sender, System.EventArgs e)
{
short i = 1234;
short j = 0;
short k = -1;
k = Convert.ToInt16(i / j);
// Note that you will never see the MsgBox statement below
MessageBox.Show("Your reults are: " + k.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
}


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: