简体   繁体   中英

Service Error 1053: Could not start in timely fashion

Before you ask, yes I searched and searched on this issue, tried what others had work for them and came up with nothing. I have tried:

  • Running in release mode
  • Running on LocalSystem, LocalService, and named account
  • I have no debug code in my project

The summary of my project is a Windows service that scans for files in a source folder and at a set time, converts them and places them in a destination folder. These settings can be changed in a GUI which changes an XML file which the service scans periodically.

The finished product is wrapped in InstallShield. Everything works from VisualStudio. I can install the program and the service works perfectly . When I take my release build and install it myself on the same machine, I get this 1053 error.

Here is my OnStart

    protected override void OnStart(string[] args)
    {
        // Update the service state to Start Pending.
        ServiceStatus serviceStatus = new ServiceStatus();
        serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING;
        serviceStatus.dwWaitHint = 100000;
        SetServiceStatus( this.ServiceHandle, ref serviceStatus );

        // Set up a timer to trigger every 30s
        System.Threading.Thread t1 = new System.Threading.Thread( new System.Threading.ThreadStart( this.InitTimer ) );
        t1.Start();

        // Set folders and time from xml
        System.Threading.Thread t2 = new System.Threading.Thread( new System.Threading.ThreadStart( this.InitSettings ) );
        t2.Start();

        // Update the service state to Running.
        eventLog1.WriteEntry( "Service successfully started", EventLogEntryType.Information, eventId++ );
        serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING;
        SetServiceStatus( this.ServiceHandle, ref serviceStatus );
    }

Here is my main

    public WTVService(string[] args)
    {
        InitializeComponent();
        string eventSourceName = "Searcher";
        string logName = "WTVConverter";
        if ( args.Count() > 0 )
        {
            eventSourceName = args[0];
        }
        if ( args.Count() > 1 )
        {
            logName = args[1];
        }
        eventLog1 = new EventLog();
        if ( !EventLog.SourceExists( eventSourceName ) )
        {
            EventLog.CreateEventSource( eventSourceName, logName );
        }
        eventLog1.Source = eventSourceName; eventLog1.Log = logName;
    }

Let me know what other info might be helpful.

Edit: Also, if it makes a difference, the error comes up instantly, not after the supposed 30 second timeout rule.

So this is interesting. I'm sure the InstallShield crowd is kind of limited here, but this might help someone. What ended up working was changing the build mode from SingleImage to DVD-5 . I could not say why, but it now works perfectly. I tested on a machine that had never before run my program and it all worked.

When you are deploying any service through InstallShield you need to either select LocalSystem username or the Admin user credentials.

For execution of any windows service, it requires Admin user or LocalSystem user.

So there is provision of user credentials fr a servive in InstallShield.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM