Click here to Skip to main content
15,915,810 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got an error when entering unspecified character in textbox.
So that catch does its work and windows forms gets closed automatically.
Here I want to resume the windows page without closing.

Or


I want to use goto statement so that it forms a loop


C#
 static void Main()
        {
          
          
            try
            {
               
           
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
              

                Application.Run(new Form1());
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
//After this the program exits


                
            }
          
        }






So I don't want to to exit the program instead the windows forms resume the previous state before try
Posted
Updated 10-Feb-14 1:23am
v2
Comments
[no name] 10-Feb-14 7:08am    
provider your code for better understanding of what logic you tried?
BillWoodruff 10-Feb-14 8:19am    
Your code example has no relationship to the question asked. Please show the code where the error occurs.

1 solution

try this

C#
}
catch (Exception exp)
{
    MessageBox.Show(exp.Message);
 Application.Run(new Form1());



}
 
Share this answer
 
Comments
KUMAR619 10-Feb-14 7:45am    
Thanks Anna I'm from Madurai
Karthik_Mahalingam 10-Feb-14 7:47am    
Nandri Kumar:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900