I have an app that is not closing properly. There is a user control that appears twice in the form. Using debug I can see the following code in Form1.Designer executed twice:
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
This makes sense to me as it is disposing of the two usercontrols. After this happens the code execution returns to the line:
Application.Run(new Form1());
In this code block.
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
I get no error messages.
I do find others recommending someone Application.Current.Shutdown() in a form closing event but that seems like it does not solve root cause.
How can I debug this issue further? Not sure where to start.