Unfortunately it's a little to big to post. Let me give you some of the background stuff and you might be able to help. It's a chat application. There are two forms. One form is the logon and the other is the chat window. I'm not sure that I am terminating the windows properly.
The logon loads first. If user authentication passes,(through a SQL 2000 DB) the chat window opens and hides the logon window using the following code:
Code:
if(password == enteredPassword)
{
ActiveForm.Hide();
FormMain chatWindow = new FormMain(enteredScreenName);
chatWindow.Closed += new EventHandler(OnSubwindowClose);
chatWindow.Show();
}
So now the logon window is hidden and the chat window can be seen and used. When I close the chat window I do this:
Code:
private void FormMain_Unload(object sender, System.EventArgs e, IAsyncResult ar)
{
ActiveForm.Close();
}
So now the chatwindow is closed but the hidden form is still alive. Then this method runs to kill the logon window.
Code:
private static void OnSubwindowClose(object sender, System.EventArgs e)
{
//Application.Exit(); Doesn't work
ActiveForm.Close(); //This was the original working config
//ActiveForm.Dispose(); Doesn't work
}
This then terminates the application when I run it through the debugger. For some reason I get that exception when I run it using the compiled exe.(Tried both the debug and release version)
[Editted] When I debug after using the exe, it tells me that the error is coming from the OnSubwindow close method. Not sure if this helps at all.
THANKS!!!