首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# MainForm程序运行时一闪而过,该如何解决

2013-11-11 
C# MainForm程序运行时一闪而过C# MainForm程序在开发环境下运行正常,编译后在某些电脑上运行正常,但在有

C# MainForm程序运行时一闪而过
C# MainForm程序在开发环境下运行正常,编译后在某些电脑上运行正常,但在有些电脑上运行时一闪而过就退出了,不知道是怎么回事!
应用程序入口代码如下:
  static void Main()
        {
            bool createNew;
            appMutex = new System.Threading.Mutex(true, "ht", out createNew);
            if (!createNew)
            {
                try
                {
                    appMutex.Close(); appMutex = null;
                    MessageBox.Show("当前程序已经运行!", "后台管理");
                }
                catch { }
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
MainForm的Load事件代码如下:
 private void MainForm_Load(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            timer1.Interval = Settings.Instance.ServerTimeSpan;
            if (Settings.Instance.ServerStat)
            {
                timer1.Start();
            }
            notifyIcon1.Visible = true;
            this.WindowState = FormWindowState.Minimized;
            this.Visible = false;
            this.ShowInTaskbar = false;
            notifyIcon1.ShowBalloonTip(1, "提示", "后台管理运行中.....", ToolTipIcon.Info);
            System.Threading.Thread.Sleep(2000);
            notifyIcon1.Visible = false;
            notifyIcon1.Visible = true;
        } C#程序编译后运行一闪而过
[解决办法]
在一闪而过的电脑上打开系统日志,贴出具体的异常信息。
[解决办法]
用F11单步调试看能跑到哪儿出异常
[解决办法]
杀毒软件的问题排除了没?

热点排行