Error 1053 The service did not respond to the start or control request in a timely manner

0

Hello! I did a windows send service and emails, however I'm getting error 1053 when trying to start it. I looked at various articles and forums and could not solve the problem. Could anyone explain to me what it could be? Follow the code.

Servico.cs

    public partial class EnvioEmailAutomatico : ServiceBase
{
    private int eventId = 1;
    private System.Diagnostics.EventLog eventLog1;

    public EnvioEmailAutomatico()
    {
        InitializeComponent();

        eventLog1 = new System.Diagnostics.EventLog();

        if (!System.Diagnostics.EventLog.SourceExists("MySource"))
        {
            System.Diagnostics.EventLog.CreateEventSource(
                "MySource", "MyNewLog");
        }
        eventLog1.Source = "MySource";
        eventLog1.Log = "MyNewLog";
    }

    protected override void OnStart(string[] args)
    {
        System.Diagnostics.Debugger.Launch();
        Timer timer = new Timer();
        timer.Interval = 300000; // 5 Minutos
        timer.Enabled = true;
        timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer);
        timer.Start();
    }

    protected override void OnStop()
    {
        eventLog1.WriteEntry("Serviço de Envio de E-mail Automático Encerrado.");
    }

    public void OnTimer(object sender, System.Timers.ElapsedEventArgs args)
    {
        eventLog1.WriteEntry("Monitorando os E-mails Agendados", EventLogEntryType.Information, eventId++);
    }

Main.cs

    public static class EnvioEmail
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    public static void Main()
    {
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new EnvioEmailAutomatico()
            };
            ServiceBase.Run(ServicesToRun);
    }
}
    
asked by anonymous 26.07.2018 / 14:00

0 answers