Reputation: 477
I have the following issue.
I have two windows services application to start in the same application (WPF), both were already installed. but when I have to "Start" them (ServiceController.Start()), only the service which starts first keeps turned on, the other returns the message:
Error 1053: The service did not respond to the start or control request in a timely fashion
This is my code to start them:
//*TS_TimeOut timespan has 1 hour
private void InitServiceOne()
{
ServiceController SControllerServiceOne = new ServiceController("ServiceOne", Environment.MachineName);
SControllerServiceOne.Start();
SControllerServiceOne.WaitForStatus(ServiceControllerStatus.Running, TS_TimeOut);
}
private void InitServiceTwo()
{
ServiceController SControllerServiceTwo = new ServiceController("ServiceTwo", Environment.MachineName);
SControllerServiceTwo.Start();
SControllerServiceTwo.WaitForStatus(ServiceControllerStatus.Running, TS_TimeOut);
}
This is the code that I've used to install them:
private void InstallServiceOne(string strServiceOnePath)
{
ServiceProcessInstaller ProcessServiceServiceOne = new ServiceProcessInstaller();
ServiceInstaller ServiceInstallerOne = new ServiceInstaller();
InstallContext Context = new System.Configuration.Install.InstallContext();
String path = String.Format("/assemblypath={0}", strServiceOnePath));
String[] cmdline = { path };
Context = new System.Configuration.Install.InstallContext("", cmdline);
ServiceInstallerOne.Context = Context;
ServiceInstallerOne.DisplayName = "ServiceOne";
ServiceInstallerOne.Description = "ServiceOne";
ServiceInstallerOne.ServiceName = "ServiceOne";
ServiceInstallerOne.StartType = ServiceStartMode.Automatic;
ServiceInstallerOne.Parent = ProcessServiceServiceOne;
System.Collections.Specialized.ListDictionary stateServiceOne = new System.Collections.Specialized.ListDictionary();
ServiceInstallerObjIntegracao.Install(stateServiceOne);
}
private void InstallServiceTwo(string strServiceTwoPath)
{
ServiceProcessInstaller ProcessServiceServiceTwo new ServiceProcessInstaller();
ServiceInstaller ServiceInstallerTwo = new ServiceInstaller();
InstallContext Context = new System.Configuration.Install.InstallContext();
String path = String.Format("/assemblypath={0}", strServiceTwoPath);
String[] cmdline = { path };
Context = new System.Configuration.Install.InstallContext("", cmdline);
ServiceInstallerTwo.Context = Context;
ServiceInstallerTwo.DisplayName = "ServiceTwo";
ServiceInstallerTwo.Description = "ServiceTwo";
ServiceInstallerTwo.ServiceName = "ServiceTwo";
ServiceInstallerTwo.StartType = ServiceStartMode.Automatic;
ServiceInstallerTwo.Parent = ProcessServiceServiceTwo;
System.Collections.Specialized.ListDictionary stateServiceTwo = new System.Collections.Specialized.ListDictionary();
ServiceInstallerObjBRMonitoring.Install(stateServiceTwo);
}
It's my first question in the stackoverflow community and english is not my mother tongue. My apologies if I commited any mistake.
Upvotes: 2
Views: 87
Reputation: 477
The problem have been solved!
I just had to change from Debug to Release and Install the Release .exe, now both services are running and working without any problem.
Upvotes: 1