Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WinForms application needs to close unhandled exception [duplicate]

I have a windows forms application. It is implemented like a tray icon so when a message arrives it pops up above all other windows. Somehow I have an unhandled exception on a few systems:

Mnclient has encountered a problem and needs to close. We are sorry for the inconvenience.

Report contains next:

EventType : clr20r3 P1 : mnclient.exe P2 : 1.0.0.0 P3 : 51dec1c0 P4 : system P5 : 4.0.0.0 P6 : 50485745 P7 : 57f
P8 : 0 P9 : system.io.filenotfoundexception\

I can't catch this error in my code. What could be the reason?

BTW If I don't close this error-report window, my app continues to work as everything is fine.

So I'm thinking that some system component is trying to close it. But is it possible? And why?

Any other ideas?

like image 639
Ksice Avatar asked Jun 11 '26 16:06

Ksice


1 Answers

Create a handler for UnhandledException in your program so that it can help you debug the issue further and handle the exception from wherever it's been thrown (as well as other unhandled exceptions). For example

AppDomain.CurrentDomain.UnhandledException += (s,e) => 
               {
                  Exception ex = (Exception)e.ExceptionObject;
                  Debug.WriteLine(ex.Message);                                          
               };
like image 186
keyboardP Avatar answered Jun 14 '26 06:06

keyboardP



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!