I am getting error while I am trying to handle FormClosing on
Environment.Exit(0);
System.ComponentModel.Win32Exception was unhandled
HResult=-2147467259 Message=Error creating window handle.
Source=System.Windows.Forms ErrorCode=-2147467259
NativeErrorCode=1406 StackTrace: at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) at System.Windows.Forms.Control.CreateHandle() at System.Windows.Forms.ComboBox.CreateHandle() at System.Windows.Forms.Control.get_Handle() at System.Windows.Forms.ComboBox.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) InnerException:
private void F0103_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult result;
result = MessageBox.Show("are you sure you want to exit", "quite confrimation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
Environment.Exit(0);
}
else
{ e.Cancel = true; }
}
I tried to change Environment.Exit(0);
to below but I fail
Environment.Exit(1);
Application.Exit();