I have this code in a form
The form is empty.
There is no button, so no button named b1.
This code crashes, but the strange thing is it gives no exception.
I know it crashes, because it doesn't reach that MessageBox.Show line.
private void Form1_Load(object sender, EventArgs e) {
Control[] controlsreturned = this.Controls.Find("b1", false);
MessageBox.Show(controlsreturned.Length.ToString()); //0
controlsreturned[0].ToString(); // intentional crash to demonstrate issue
MessageBox.Show("reached here?"); // is not reached! but no exception thrown!
}
As a test, one could try adding Button b1 = new Button(); b1.Name = "b1"; this.Controls.Add(b1);
and then it won't crash.
But my point is, why is it that when it crashes it doesn't throw an exception, it just crashes very silently. The program continues to run.. no exception is thrown. This is of course a slightly bigger inconvenience in a larger program as it makes it a bit more work to debug. But I use a small example to demonstrate.