Windows Service - Error 1053 When Starting

1

Hello,

I have a windows service in C # that I have to install on several clients. My problem is that on some clients I can install and it works normally, however on some clients I can install the service but it does not start at all. I barely start the service and it gives me the message

  

"Error 1053: The service can not be initialized because it did not respond to the request in a timely manner"

If it was a service error I would be able to see the logs in the Event Viewer of windows, but the problem is that no log appears, which is leading me to believe that the service is not even being and the error occurs before it starts.

One solution I tried so far was to create a key in the windows registry called ServicesPipeTimeout hoping the error was that the wait time for the start of the service was very small, but unfortunately it did not solve .

On my computer and many other clients the service works normally, however in a few it presents this error, it may be some version problem, but these clients have nothing in common. How to proceed?

Hugs!

    
asked by anonymous 30.12.2014 / 19:46

2 answers

3

The problem was that on the latest client computers, you had installed version 4.5 of the .NET Framework, whereas on the other clients the installed version was 4.0.

My application was compiled for the 4.5 framework, I changed it through the 4.0 Client Profile and recompiled the entire executable, so it worked.

    
06.01.2015 / 16:49
3

If the error persists, the best thing to do is try to debug the service, as indicated by @KhaosDoctor.

When I need to debug something, I put try catch everywhere and I have a class of my own to add log to a specific path. Nothing special but it has helped me a lot:

using System;
using System.IO;

namespace SystecNFCe.Model
{
public class Logger
{
    public void addLog(string str, bool booForcarDataMaquina = true, bool booGerarLog = true)
    {
        StreamWriter arquivoWS = null;

        Util util = new Util();

        String Path = System.AppDomain.CurrentDomain.BaseDirectory + @"Logs\";
        String Time = "";

        if (!booGerarLog) //se for pra nao gerar log, pular fora da funçao
        {
            return;
        }

        try
        {
            //verifica se existe o diretorio
            if (System.IO.Directory.Exists(Path) == false)
            {
                System.IO.Directory.CreateDirectory(Path);
            }

            //verifica se existe o arquivo com a data de hoje
            if (arquivoWS == null)
            {
                arquivoWS = new StreamWriter(Path + "SystecNFCe" + DateTime.Now.Date.ToString("yyyy_MM_dd") + ".log", true);
            }

            if (booForcarDataMaquina == false)
            {
                Time = util.GetTimeStampLog();

                if (Time.ToString().Trim() == "")
                {
                    Time = "LOCAL TIME[" + DateTime.Now + "]";
                }
            }
            else
            {
                Time = "LOCAL TIME[" + DateTime.Now + "]";
            }

            arquivoWS.WriteLine(Time + " - " + str); //escreve no log (data/hora - o log que queremos) 
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.Print(ex.Message);
        }
        finally
        {
            arquivoWS.Flush();
            arquivoWS.Dispose();
            arquivoWS = null;
            util = null;
        }
    }

}

}

    
04.07.2016 / 16:56