The service on local computer started and then stopped. some services stop automatically if they have no work to do,for example,the performance logs and alerts service.why?

解决方案 »

  1.   

    我在server上安装了个service,但是在不能够启动,一启动就报上面的错误。什么原因呢?怎么解决呢?
             
    private void InitializeComponent()
            {
                this.timer1 = new System.Timers.Timer();
                ((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
                // 
                // timer1
                // 
                this.timer1.Enabled = true;
                this.timer1.Interval = 60000;
                this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Tick);
                // 
                // UpdateUserService
                // 
                this.ServiceName = "UpdateUserService";
                ((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();        }protected override void OnStart(string[] args)
            {
                // TODO: 在此处添加代码以启动服务。
                this.timer1.Enabled = true;
                log("WindowsServiceLog: Service Started.");
            }        protected override void OnStop()
            {
                // TODO: 在此处添加代码以执行停止服务所需的关闭操作。
                this.timer1.Enabled = false;
                log("WindowsServiceLog: Service Stopped.");
            }        protected void timer1_Tick(object sender, EventArgs e)
            {
                //log("*************" + System.DateTime.Now);
                if (System.DateTime.Now.Hour == 14 && System.DateTime.Now.Minute==50)
               // if (System.DateTime.Now.Hour == 20)
                {
                    doExcel();
                }
            }        protected void doExcel()
            {
                ........
             }
      

  2.   

    我在事件查看器中查不到这个service.