C# windows form closes immediately

Jan 13 2015 4:41 AM
Hello,
 
I have a windows form which I am trying to open from another application. While running the utility, the form is opening and closing immediately. I have tried to debug but didnt get any clue. Please help me in solving the problem.
 Thanks in advance.
 
My code looks like this....
 

 public WinForm()
        {
            //Set the Language property....
            oCurrentLangSet = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Globalization.CultureInfo oCurrentCultInfo = new System.Globalization.CultureInfo("en-US");
            System.Threading.Thread.CurrentThread.CurrentCulture = oCurrentCultInfo;

            InitializeComponent();
         }
 
 public static void Main(string[] args)
        {
                           if (sampleForm == null)
                {
                    try
                    {
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        //Application.Run(new WinForm());
                        sampleForm = new WinForm();
                        sampleForm .Show();
                        //sampleForm .ShowDialog();
                       
                        MBox.Show("Form", NXMessageBox.DialogType.Information, "form loaded");
                    }
                        
                    catch (Exception ex)
                    {
                        
                    }
                }
                else
                   
            {
                try
                {
                   if (sampleForm .WindowState == FormWindowState.Minimized)
                        sampleForm .WindowState = FormWindowState.Normal;
                }
                catch (Exception ex)
                {
                  
                }

            }
           

        }


Answers (1)