Adrian Albu

Adrian Albu

  • NA
  • 11
  • 0

Could not start service... Error 1053 time stuff

Jul 15 2008 10:06 AM
Hi,

I just create and use the log in the service, the other code to start the processes is commented it out and not present here.

But after installation of service when I want to start it gives this error, I do not see
any time consuming stuff here. I used vs 2005 c3 windows service project.

public partial class TestService : ServiceBase
    {
        private bool loggingEnabled;
        private string logName;
        private EventLog log;

        public enum DataProvider
        {
            Oracle, SqlServer, OleDb, Odbc
        }

        public TestService()
        {
            InitializeComponent();

            this.logName = ConfigurationManager.AppSettings["LogName"];
            if (ConfigurationManager.AppSettings["LoggingEnabled"] == "true")
               this.loggingEnabled = true;
            else
               this.loggingEnabled = false;
     
            if (this.loggingEnabled)
            {
                if (!EventLog.SourceExists(this.ServiceName))
                    EventLog.CreateEventSource(this.ServiceName, this.logName);
                else
                {
                    EventLog.Delete(this.ServiceName);
                    EventLog.CreateEventSource(this.ServiceName, this.logName);
                }

     
               this.log = new EventLog();
               this.log.Log = this.logName;
               this.log.Source = this.ServiceName;  
            }
        }

        private void Log(string message, EventLogEntryType type)
        {
            if (this.loggingEnabled)
                this.log.WriteEntry(message, type);
        }

        private void Log(string message)
        {
            this.Log(message, EventLogEntryType.Information);
        }

        private void Log(Exception e)
        {
            this.Log(e.Message + "\n" + e.StackTrace,   EventLogEntryType.Error);
        }

        protected override void OnStart(string[] args)
        {
            this.Log(this.ServiceName + " Started, at: " + DateTime.Now);            
        }

        protected override void OnStop()
        {
            this.Log(this.ServiceName + " Stopped, at: " + DateTime.Now);
        }
}

Thanks!

PS: do not see the event folder created in event Viewer and not in registry also.

Answers (1)