ObjectDisposed exception

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I develop a simple smart device application and sometimes when i exit the
application, im getting an objectdisposed exception cause by
system.windows.forms.dll. Is there a way in compact framework that when they
click exit button, i will just execute a simple command that will end the
application even though there is an error message.

Thanks,

Lito
 
Not really. Where are you getting the exception, on what line (there must be
more info in the dialog that informs you of the exception)? Try to deal with
it or worst case just swallow it with a try..catch.

Cheers
Daniel
 
Hello Daniel,

This is a code that i used when exit button was pressed

Public Sub Exit_Main()
Try
Me.Close()
Application.Exit()
Catch e As Exception
Application.Exit()
Me.Close()
End Try
End Sub

but for some reason it does'nt catch the exception, when i run on debug,
the program stop on Public Class frmMain.

Genesis
 
When you close main form, you should not call Application.Exit(). Indeed
Application.Exit sends WM_DESTROY message but Me.Close sends WM_CLOSE
message (that is more correct way to close your application).

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
Is this in the main form (the one you passed to Application.Run)? If it is,
then you don't need the Application.Exit. If it isn't, then design your
forms so they navigate back to the main form and close that (again, not
needing Application.Exit). If you really want to use Application.Exit, don't
use Me.Close().

Cheers
Daniel
 
Back
Top