Tutorial :Error 1053 the service did not respond to the start or control request


I've written a Windows Service in C# that basically checks my db every minute for orders, generates a PDF from these orders, and emails it.

The logic works perfectly in my tests etc..

When i create the service, and install it using the setup project, when I go to start the service in the services mmc, I get:

error 1053 the service did not respond to the start or control request in a timely fashion

My OnStart method looks like this:

protected override void OnStart(string[] args)  {      //writeToWindowsEventLog("Service started", EventLogEntryType.Information);      timer.Enabled = true;  }  

Basically, just enables the timer... so theres no process intensive call there.

Where am I going wrong?

I've tried setting the startup account to local system, network service etc... nothing works!


Here is my code: (processPurchaseOrders is the method where the db is queried and pdf's are generated etc...)

public partial class PurchaseOrderDispatcher : ServiceBase  {      //this is the main timer of the service      private System.Timers.Timer timer;        public PurchaseOrderDispatcher()      {          InitializeComponent();      }        // The main entry point for the process      static void Main()      {        #if (!DEBUG)          ServiceBase[] ServicesToRun;          ServicesToRun = new ServiceBase[] { new PurchaseOrderDispatcher() };          ServiceBase.Run(ServicesToRun);        #else //debug code          PurchaseOrderDispatcher service = new PurchaseOrderDispatcher();          service.processPurchaseOrders();        

Next Post »