Service did not start within a timely fashion - c# windows service
I have a Windows service which I can install on my local machine using
installutil no problem.
Now, this service has to be installed on a server. I copy all files to the
server and run the same command, set the service to log on as a local user
account and when the service starts I get an error saying "logon failed" -
okay so perhaps the user account is the issue.
So I change the service log on as to local system account. I start the
service and I am told "The service did not respond to the start or control
request in a timely fashion".
So I googled and tried various solutions but to no avail. So I got to
thinking maybe it was something in the OnStart method which broke (even
though I have logging calls which never logged). So I removed all code
from the OnStart event and still the service would not start, I got the
"timely fashion" error.
So where am I at? I believe it could be due to the references I have
defined in the project. To test this I created a new Windows service
template from VS2012 with no references (other than the default ones) and
I can start the service. No issues.
So my question is what could be causing this? In my project the references
point to locations which do not exist on the server, however the directory
where the service resides has all the referenced DLLs.
Edit: Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace RetrieveAndProcessSecurityLogs
{
static class Program
{
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new LogService()
};
ServiceBase.Run(ServicesToRun);
}
}
}
LogService.cs
public partial class LogService : ServiceBase
{
public LogService()
{
InitializeComponent();
this.ServiceName = "Retrieve and Process Security Logs";
this.CanPauseAndContinue = true;
this.CanStop = true;
}
protected override void OnStart(string[] args)
{
//...
}
protect override void OnStop()
{
//...
}
Sorry for the story. Andrew
No comments:
Post a Comment