Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application Error thrown in Compact Framework app on Windows Ce 6.0

I get an application error thrown when I close the program using as cancel button which all it does is close the form.

The error says: "Application appName.exe encountered a serious error and must shut down"

How do I start fixing it? It is not a thrown exception; no other info is given. What could it be and how do I fix it?

like image 672
sarsnake Avatar asked Feb 28 '23 06:02

sarsnake


1 Answers

Here is what it was. My application has two forms - login and main form where all the action happens. The login form has two buttons (Login and Cancel). Login button logs user in, closes the login form and opens the main form. Cancel button just closes the login form. To close the form I simply used this.Close().

What was happening though is that I still needed to dispose of the login form explicitly by doing something like:

frmLogin.Dispose();
frmLogin = null;

before exiting the program (in my Program.cs)

So this solved it. I had to make sure that this was being done in both cases: when the user logs in as well as when they choose to not log in.

Crucial fact is that frmLogin is modal, hence Dispose() is not called automatically when closed.

like image 162
sarsnake Avatar answered May 09 '23 20:05

sarsnake