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;
}
------解决方案--------------------
在一闪而过的电脑上打开系统日志,贴出具体的异常信息。
------解决方案--------------------
用F11单步调试看能跑到哪儿出异常
------解决方案--------------------
杀毒软件的问题排除了没?
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单步调试看能跑到哪儿出异常
------解决方案--------------------
杀毒软件的问题排除了没?