using System;
using System.Collections.Generic;
using System.Windows.Forms;namespace SMS
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            
            frmLogin frm = new frmLogin();
            frm.ShowDialog();
            if (frm.login_Success)
            {
                Application.Run(new frmMain());
               
            }
            else
                Application.Exit();
            
        }
    }
}
主窗口出来就关闭了,怎么办?

解决方案 »

  1.   

    在代码最后加上Console.ReadLine()就可以了
      

  2.   


    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;namespace SMS
    {
        static class Program
        {
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
               
                Application.Run(new frmLogin());         
            }
        }
    }然后在frmLogin里校验是否成功,成功就可以
                frmMain frm = new frmMain();
                this.hide();
                frm.ShowDialog();