Is it possible to disable all errors in C# winform application?
I wan't to hide/disable that messages:
Asked
Active
Viewed 1,378 times
-3

Rowland Shaw
- 37,700
- 14
- 97
- 166

Dewagg
- 145
- 10
-
4Sure, it's possible to catch pretty much all exceptions and ignore them. The real question here is why would you want to do that? – Saragis Jul 06 '15 at 18:45
-
@Saragis because I don't know where is the bad code :( – Dewagg Jul 06 '15 at 18:46
-
2You can ask Visual Studio to break when an exception is thrown. That'd be a real good start... – Rowland Shaw Jul 06 '15 at 18:47
-
@Dewagg That would just amount to a empty `catch { }` block. However as Saragis said it would be better to deal with or at the very least log the errors somewhere. – bumble_bee_tuna Jul 06 '15 at 18:48
-
Debug -> Exceptions -> Check 'Thrown' on the first two. Press OK, re-run your application – Jonesopolis Jul 06 '15 at 18:48
-
What info does the details button provide? It will point you to the error in your code. You have a simple object not set error. – SoftwareCarpenter Jul 06 '15 at 18:50
-
object reference exceptions usually point to bugs in the application. Why ignore those ? – Philip Stuyck Jul 06 '15 at 19:00
1 Answers
0
See the AppDomain.UnhandledException event. Just assign a handler as the first bit of code in your application and you can do whatever you want with unhandled errors.
AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
{
//handler code
};
However, see the first comment to your post...are you SURE you want to do that? You never know what kind of errors you might be swallowing at that point.

Steve Danner
- 21,818
- 7
- 41
- 51
-
2Would probably be best to attach to Application.ThreadException as well, since it's WinForms. – Saragis Jul 06 '15 at 18:52