Service doesn't start-up

Hi there,

I wrote an windows service and starting it manually, it works fine.
But it just won't start on windows start-up and I don't know why.
When windows starts, my service's status is "Getting startet...". And that's it!
Once I click on "start service" it starts and works fine!

Here is the code I'm using:

[RunInstaller(true)]
public class ProjectInstaller : Installer
{
   public ProjectInstaller()
   {
      ServiceProcessInstaller spi = new ServiceProcessInstaller();
      spi.Account = ServiceAccount.LocalService;
      //spi.Account = ServiceAccount.LocalSystem;   //I tried that as well...
      
ServiceInstaller si = new ServiceInstaller();
      si.ServiceName = "AssetDataCollector";
      si.StartType = ServiceStartMode.Automatic;
      Installers.AddRange(new Installer[] {spi, si});
   }
//ProjectInstaller
...

I acrually didn't write this code, the IDE wrote it...

Thanks,

Finch.



Answer this question

Service doesn't start-up

  • Krishnaswin

    I located the problem:

    It was not due to my empty OnStart()-Method. It is still empty...
    The problem was cased by the FTP-connection I establish. When the server cannot be reached, the service won't start automatically, but can be started manually.
    Since my service get's alot of information about the computer using WMI, I have to wait until all drivers and devices are ready, so I added the following depency:
    si.ServicesDependedOn = new string[] {"winmgmt"};

    No everythink works like it's supposed to!


    Thanks everybody for helping me,

    Finch.


  • Bio_Hazard

    Could you post the code you have in the OnStart method   This is where the problem is occurring.  Do you have a dependency on something like connecting to a DB or something like that   If so then you'll need to modify your service installation code to set up a dependency on the appropriate service otherwise you'll likely deadlock.  It could also be a network dependency if you are using COM inside your service.

    Michael Taylor - 11/28/05

  • Service doesn't start-up