I have a try catch like this that handled the error and give me a message box that shows the error, but in running i give error notification in try catch block and i'm so tired of that. This situation not happened before.what am i doing?
Asked
Active
Viewed 467 times
-1

Mahdi Ahmadi
- 441
- 4
- 12
-
You just press `F5` and let it continue, it'll go to `catch`. But I do not see a code in `catch` to show any message box. – Arghya C Nov 29 '15 at 05:52
-
41) Please use text (instead of screenshots) whenever possible. 2) Q: What am I doing? A: You're getting an ArgumentOutOfRangeException trying to access `this.Controls[0]`. 3) If you had a non-empty catch block, you'd see the same exception, and it would point to the same line. SUGGESTIONS: 1) fix "Controls[0]" by referencing your actual WinPart (whatever/wherever it is), then 2) implement a "catch Exception ex" block (and take the appropriate action). Either in frmContainer_formClosing(), or at some higher-level. – paulsm4 Nov 29 '15 at 05:53
-
You are not catching any type of exception. Your Catch block must have Exception Argument. – Bhavik Patel Nov 29 '15 at 05:55
-
Possible duplicate of [Why doesn't try {} catch{} work in C#?](http://stackoverflow.com/questions/33967818/why-doesnt-try-catch-work-in-c) – Ghasem Nov 29 '15 at 07:20
1 Answers
0
You're trying to access the first element of this.Controls array (this.Controls[0]
), but seems there are no elements in that.
Please check the array in debug mode and why the values are not in the object.
Note: Never keep catch block empty, since it hides any exceptions and you will be in trouble when troubleshooting !

user836846
- 74
- 2