Error 1053: el servicio no respondió a la solicitud de inicio o control

He escrito un servicio de Windows en C # que básicamente comprueba mi db cada minuto para pedidos, genera un PDF de estos pedidos y lo envía por correo electrónico.

La lógica funciona perfectamente en mis pruebas, etc.

Cuando creo el servicio y lo instalo utilizando el proyecto de configuración, cuando inicio el servicio en mmc, obtengo:

error 1053 el servicio no respondió a la solicitud de inicio o control de manera oportuna

Mi método OnStart se ve así:

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

Básicamente, solo habilita el temporizador ... así que no hay un proceso intensivo de llamada allí.

¿A dónde me voy mal?

He intentado configurar la cuenta de inicio en el sistema local, el servicio de red, etc ... ¡nada funciona!

Editar:

Aquí está mi código: (processPurchaseOrders es el método en el que se consulta la base de datos y se generan los pdf, 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();
      #endif
    }

    private void InitializeComponent()
    {
        this.CanPauseAndContinue = true;
        this.ServiceName = "Crocus_PurchaseOrderGenerator";
    }

    private void InitTimer()
    {
        timer = new System.Timers.Timer();

        //wire up the timer event
        timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);

        //set timer interval
        var timeInSeconds = Convert.ToInt32(ConfigurationManager.AppSettings["TimerIntervalInSeconds"]);
        timer.Interval = (timeInSeconds * 1000); // timer.Interval is in milliseconds, so times above by 1000

        timer.Enabled = true;
    }

    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
            components.Dispose();

        base.Dispose(disposing);
    }

    protected override void OnStart(string[] args)
    {
        //instantiate timer
        Thread t = new Thread(new ThreadStart(this.InitTimer));
        t.Start();
    }

    protected override void OnStop()
    {
        //turn off the timer.
        timer.Enabled = false;
    }

    protected override void OnPause()
    {
        timer.Enabled = false;

        base.OnPause();
    }

    protected override void OnContinue()
    {
        timer.Enabled = true;

        base.OnContinue();
    }

    protected void timer_Elapsed(object sender, ElapsedEventArgs e)
    {
        processPurchaseOrders();
    }
}

Respuestas a la pregunta(12)

Su respuesta a la pregunta