That's what it was. My application has two forms: login and the main form, where all the action takes place. The login form has two buttons (Login and Cancel). The login button registers the user, closes the login form and opens the main form. The Cancel button simply closes the login form. To close the form, I just used this.Close ().
What happens is that I still have to explicitly manage the login form, doing something like:
frmLogin.Dispose(); frmLogin = null;
before exiting the program (in my .cs program)
So that solved it. I had to make sure that this happens in both cases: when the user logs in, and also when they do not want to log in.
The important thing is that frmLogin is modal, so Dispose () is not called automatically when it closes.
source share