我在使用Windows窗体的C#中有一个应用程序。我的应用程序运行正常,但是当我想通过使用计划任务的OS(Windows 7)启动它时,它不会加载Form1_load方法。我怎么能解决这个问题?当由计划任务启动时,应用程序不执行Form1_load方法
这里是Form1_Load方法的主体:
private void Form1_Load(object sender, EventArgs e)
{
try
{
bool fResult = false;
fResult = registerDeviceNotification();
g_oGeneratorManager = new CGeneratorManager();
if (true != fResult)
{
Debug.WriteLine("Register device notification failed");
MessageBox.Show("Register device notification failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
lblStatus.Text = "Running";
}
catch (Exception ex)
{
this.Visible = false;
CLog.Err(ex.Message);
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
}
专业提示,不要把问题标题内的标签。标签显示为问题的一部分,因此是多余的。你在使用什么操作系统?该计划是否复杂?我们可以看到“Form_Load”方法中的内容吗? – Arran
不会抛出异常? –
您的操作系统是64位版本吗? – Steve