Windows Service - Error 1053 on Start

Asked

Viewed 5,590 times

1

Hello,

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

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

If it was a service error I could see the logs on Event Viewer windows, but the problem is that no log appears, which is leading me to believe that the service is not even running and the error happens before it even starts.

One solution I tried so far was to create a key in the windows registry called Servicespipetimeout hoping the error was that the waiting time limit for the start of the service was too short, but unfortunately did not solve.

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

Hugs!

  • Debugging service is hell. Put the code you are using on the service startup as well as the version of .Net. Even, make sure it matches the version (and the KB’s) installed on the machines that work.

  • I checked on the machines, but one of the solutions I found was to install an update of Visual C++ 1.1 that should come in a windows update. But this Hotfix is only for Windows Server 2008 and the machine system is Windows Server 2003 or Windows Server. I tried to look for problems in these OS’s but I can’t find anything from Microsoft

2 answers

3

If the error persists, the best thing to do is to 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 to add log in a specific path. Nothing special, but it’s helped me enough:

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;
        }
    }

}

}

3


The problem was that on the computers of the newer clients, it had installed version 4.5 of . NET Framework, while for other clients the installed version was 4.0.

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

  • Hello, I’m having the same problem, however I changed my version and still nothing :/ Have any idea what else I can try?

  • What I realized may also be the cause of these problems is an exception within the system. Any type of error within the system is the cause of this problem. Ideally you should debug the programs using the option to display all VS errors.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.