Hi,
I have a problem when I try to close my Win application.
I have done something like that:
1. I have a StartForm that is the form I put in the main:
Application.Start(new StartForm());
2. Inside this form I make a thread that creates another form. The thread is
necessary to let the application faster. This Form is called Form1. When the
thread has instanced Form1 appears a button to let Form1 showing.
3. When Form1 is showed I do: StartForm.Hide();
4. Everything works properly in Form1.
5. When I close Form1 I would like to close everything, so I put in
Form1_Closed the method Application.Exit()
......but when I close Form1 I receive three times these unhandled
exceptions - where is my mistake?:
An unhandled exception of type 'System.NullReferenceException' occurred in
system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.
Unhandled Exception: System.NullReferenceException: Object reference not set
to an instance of an object.
at System.Windows.Forms.IConnectionPoint.Unadvise(Int 32 cookie)
at System.Windows.Forms.ConnectionPointCookie.Disconn ect()
at System.Windows.Forms.ConnectionPointCookie.Finaliz e()An unhandled
exception of type 'System.NullReferenceException' occurred in
system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.
Unhandled Exception: System.NullReferenceException: Object reference not set
to an instance of an object.
at System.Windows.Forms.IConnectionPoint.Unadvise(Int 32 cookie)
at System.Windows.Forms.ConnectionPointCookie.Disconn ect()
at System.Windows.Forms.ConnectionPointCookie.Finaliz e()An unhandled
exception of type 'System.NullReferenceException' occurred in
system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.
Unhandled Exception: System.NullReferenceException: Object reference not set
to an instance of an object.
at System.Windows.Forms.IConnectionPoint.Unadvise(Int 32 cookie)
at System.Windows.Forms.ConnectionPointCookie.Disconn ect()
at System.Windows.Forms.OleInterfaces.StopEvents()
at System.Windows.Forms.OleInterfaces.Finalize()The program '[1892]
TestApplication.exe' has exited with code 0 (0x0).
thank you
Bart