|
We are developing windows application in VS2005 (VB.Net). I have placed resource clearing and audit entry in the "MyApplication_Shutdown" event. But this event is not getting fired when our application exits.
When I tired with the sample application, in our system it works fine. I don't know whether I have disabled any setting so that this event does get fired.
Note: I have checked application framework checkbox in application settings.
|
| Nandagopal Tuesday, November 07, 2006 5:22 AM |
Project + properties, Application tab, Shutdown mode = When last form closes. You can now close your login form without ending your app and the Shutdown event should fire when you close your main form.
|
| nobugz Tuesday, November 07, 2006 9:52 AM |
|
| SvenC Tuesday, November 07, 2006 5:38 AM |
Hi Sven,
I followed as given in the url sent by you. I even checked whether our application gets to abnormal exit.
Nandagopal.P.K.S
|
| Nandagopal Tuesday, November 07, 2006 6:46 AM |
Looking at the WindowsFormsApplicationBase class, the Shutdown event is fired right after Application.Run() exits. Not seeing this event means that Application.Run() doesn't exit normally. The only thing I can come up with: an unhandled exception. Do you trap the UnhandledException event?
Alternatives are to write an Application.ApplicationExit event or to not use not use the application framework and go back to plain-jane Main.
|
| nobugz Tuesday, November 07, 2006 6:52 AM |
I followed the sample and had no problems hitting Shutdown.
Is your event handler really in the partial MyApplication class of your vb project? Does the function declaration end on Handler Me.Shutdown?
-- SvenC |
| SvenC Tuesday, November 07, 2006 6:58 AM |
Hi I could get the problem.
We have a login screen as startup. If the login is valid we do the following frmLogin.hide() frmMain.show()
Since we hide the screen, the shutdown event is not getting fired when we close the frmMain.
Alternatively. frmLogin.close() frmMain.show()
In this case the shutdown events gets fired, but my frmMain also getting closed. How to handle this.
Nandagopal.
|
| Nandagopal Tuesday, November 07, 2006 7:24 AM |
Just combine the calls:
frmLogin.Hide() frmMain.Show() frmLogin.Close()
-- SvenC |
| SvenC Tuesday, November 07, 2006 7:29 AM |
Its not working.
Nandagopal
|
| Nandagopal Tuesday, November 07, 2006 9:36 AM |
Project + properties, Application tab, Shutdown mode = When last form closes. You can now close your login form without ending your app and the Shutdown event should fire when you close your main form.
|
| nobugz Tuesday, November 07, 2006 9:52 AM |
Nandagopal, I was having a similar issue. I used Nobugz suggestion and it still didn't work. I then looked at the statement my application was using to close to program. I had some places where an application used the "End" statement. I changed the "End" statement to "application.exit" and then Nobugz suggestion worked for me. I discovered another issue too. If you have a form that is hidden and was not closed, then this stopped the shutdown event from firing too. This probably seems obvious, but it might be a problem someone else has overlooked. I hope this helps. |
| James12314909 Monday, October 05, 2009 4:22 PM |