locked
Would unsigned dll's cause a timeout error when trying to start a windows service ? RRS feed

  • Question

  • User1253338400 posted

    Hi ,

    I have a windows service that i install and start up using the following code snippet.

    ServiceController sc  = new ServiceController();
    sc.ServiceName = "TEST";


    if (sc.Status == ServiceControllerStatus.Stopped)
    {
       try
       {
          sc.Start();
          sc.WaitForStatus(ServiceControllerStatus.Running,  TimeSpan.FromSeconds(60.000));     
       }
       catch (InvalidOperationException)
       {
          Console.WriteLine("Could not start the TEST service.");
       }
    }

    The login for this service is a Domain user, all used to work. But the dll's are unsigned for the moment. 

    Could that cause an error with starting up the service ?

    Thursday, June 25, 2020 7:21 AM

Answers

  • User288213138 posted

    Hi robby32,

    I have a windows service that i install and start up using the following code snippet.

    ServiceController sc  = new ServiceController();
    sc.ServiceName = "TEST";


    if (sc.Status == ServiceControllerStatus.Stopped)
    {
       try
       {
          sc.Start();
          sc.WaitForStatus(ServiceControllerStatus.Running,  TimeSpan.FromSeconds(60.000));     
       }
       catch (InvalidOperationException)
       {
          Console.WriteLine("Could not start the TEST service.");
       }
    }

    The login for this service is a Domain user, all used to work. But the dll's are unsigned for the moment. 

    According to you description, in order to find the cause of the error, you need to tell us what did you do before you started a windows service?

    Best regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 26, 2020 6:53 AM

All replies

  • User753101303 posted

    Hi,

    You don't have an error for this service in the Windows event viewer? Could this account be blocked or whatever. Anyway try to always start from an actual error message rather than trying to guess what could cause a given generic error.

    Thursday, June 25, 2020 7:54 AM
  • User1253338400 posted

    Hi ,

    I have added some debug to event viewer. I get the following:

    "Error: Time out has expired and the operation has not been completed"

    So does that mean I need to increase the timeout , i thought 60 is quite long.

    Thursday, June 25, 2020 9:18 AM
  • User753101303 posted

    Try without a timeout and see what happens.

    What I meant is that my first move would be to try to start this TEST service by hand. I'm trying to understand if the TEST service starts fine and the timeout is really not long enough or if you do have some problem with this TEST service.

    Depending on what it does and how it is written it could be also that this service takes a long time to start if it does too many sthing at startup.

    In short does this TEST service finally starts or not ?

    Thursday, June 25, 2020 12:11 PM
  • User1253338400 posted

    I have set it with no timeout . The service does not eventually start up. The error is the same.

    The only thing i can think of is the domain login account. 

    I will put together a small app that uses the same code to create and start a windows service as I am using at the moment and try to run a windows service with that domain account and see if it starts up , 

    That will be the next step , and i will log the errors if there are any. That I think would be the next logical step ?

    Thursday, June 25, 2020 11:18 PM
  • User288213138 posted

    Hi robby32,

    I have a windows service that i install and start up using the following code snippet.

    ServiceController sc  = new ServiceController();
    sc.ServiceName = "TEST";


    if (sc.Status == ServiceControllerStatus.Stopped)
    {
       try
       {
          sc.Start();
          sc.WaitForStatus(ServiceControllerStatus.Running,  TimeSpan.FromSeconds(60.000));     
       }
       catch (InvalidOperationException)
       {
          Console.WriteLine("Could not start the TEST service.");
       }
    }

    The login for this service is a Domain user, all used to work. But the dll's are unsigned for the moment. 

    According to you description, in order to find the cause of the error, you need to tell us what did you do before you started a windows service?

    Best regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 26, 2020 6:53 AM
  • User753101303 posted

    I meant running services.msc or the command line net start/stop to see if the TEST service can start.

    For now it seems ti me you are focused on the code that tries to start the service while I suspect it could be a problem in  this TEST service that prevents him to run or even start. I would expect something in the Windows event log giving more details about what happens.

    Friday, June 26, 2020 7:46 AM