I am making a program that connects to sql server and manage data on it. So, I made a form splash screen to check if the server is running and load some needed data from it like settings.
The problem is the form don’t disappear when my main form loads. I have tried:
this.Hide();
And it doesn’t work. The form stays shown and if I used
private void loading_Load( object sender , EventArgs e )
{
// some stuff to do
start();
}
private void start()
{
main form = new main( );
form.Show( );
this.Close( );
}
An error shows in line
static void Main( )
{
Application.EnableVisualStyles( );
Application.SetCompatibleTextRenderingDefault( false );
Application.Run( new loadingfrm( ) ); // this line gets error
}
in program.cs
file.
It says trying to use disposed resource and the program closes completely without showing any form .