3

I have a Windows service application which I have installed on my machine without issue. I went to install it on another machine, and I'm receiving the error

Error 1001. An exception occurred during the Commit phase of the installation. This exception will be ignored and installation will continue. However, the application might not function correctly after installation is complete. Cannot start service MyService on computer ‘.’. The service did not respond to the start or control request in a timely fashion.

This error is popping up immediately without any hanging. Normally I would only expect to see this error after a hang.

I'm using the .NET 4 framework, which is installed on both machines. I've tried disabling the antivirus program thinking that might be interfering with the service startup, but that yielded the same error. The firewall was also disabled.

Is there anything else that could be causing this issue?

Poosh
  • 532
  • 2
  • 10
  • 25
  • Almost certainly an exception is happening, probably on startup. Do you log exceptions that would otherwise escape your service implementation? – Kirk Woll May 30 '12 at 23:07
  • Yes, in the OnStart operation, I'm catching an exception with the following details: **Exception Message:** Cannot start service CHD on computer '.' **Stack Trace:** at System.ServiceProcess.ServiceController.Start(String[] args) at System.ServiceProcess.ServiceController.Start() at CHD.ProjectInstaller.OnCommitted(IDictionary savedState) **Source:** System.ServiceProcess Inner Exception: System.ComponentModel.Win32Exception (0x80004005): The service did not respond to the start or control request in a timely fashion – Poosh May 30 '12 at 23:15
  • 1
    If you can tell us what work is performed by your service at start, that would help us answer your question. – hatchet - done with SOverflow May 30 '12 at 23:30
  • As an aside, OnStart must also return within 30 seconds; usually you kick off your service in a thread and then return. See http://stackoverflow.com/questions/216401/windows-service-startup-timeout – dash May 30 '12 at 23:39

3 Answers3

3

This behaviour usually occurs when an exception is thrown in the WinService's OnStart method and is not caught in a try-catch block. I believe you can check out the exception message and stack trace using the EventViewer, if not you can easily implement a simple logging functionality using the EventLog class.

Sometimes the exception is thrown because the service is not running under a privileged account. To fix this you have to configure your installer's ServiceProcessInstaller object like the following:

myServiceInstaller.Account = ServiceAccount.User;
myServiceInstaller.Username = "Domain name\User name";
myServiceInstaller.Password = "qwerty";
Thomas C. G. de Vilhena
  • 13,819
  • 3
  • 50
  • 44
  • Another common reason might be that someone has forgotten to compile it as windows service instead of winforms app. Sometimes i forget it myself because i've always use a winforms app to debug the service. – Tim Schmelter Sep 27 '12 at 13:04
3

Thanks for your help everyone. I realized the issue was due to the .NET Framework installed on the two different machines. My machine had .NET Framework 4 Client Profile and .NET Framework 4 Extended, and the other machine only had .NET Framework 4 Client Profile. Evidently for some of the components in the service need libraries that aren't present in the .NET Framework 4 Client Profile.

Poosh
  • 532
  • 2
  • 10
  • 25
1

Since your service runs on another computer, and assuming the code is the same for both, the issue may be something having to do with permissions. Ensure the account your service is running under has sufficient permissions to any folders where it writes files. If you write to the Event Log, ensure the service' account has the necessary permissions for that.