2

We have a set of .net 2.0 windows services installed on Windows Server 2003 R2 machine. They are configured to start as Local System account and start mode is Auto. All services are fail with error 1053 "The service did not respond to the start or control request in a timely fashion".

I've inserted logging to one of services and investigated that problem is outside our code. No single line of code executed.

It seems that problem with .net code permissions on the machine. But problem reproduces only on client machine (two different client with identical symptoms). On our developer and tester enviroment we can't reproduce it.

System to reproduce: OS: Windows Server 2003 R2 SP2 32bit clean install + product prerequisites: SQL Server 2005 Express SP2, .NET Framework 2 SP2 + our product

What can it be, any sugessions?

update from 07/04/2011:

File with ProcessMonitor log from the client machine: http://dl.dropbox.com/u/8982352/Logfile.zip Service process name is: ParsecServiceHost.exe

Semyon
  • 31
  • 1
  • 9
  • Does the service connect to any outside resources (database, socket server etc) that are maybe not configured? If it does connect to any outside resources can you connect to these outside of the service? – Cole W Jun 08 '11 at 17:18
  • Service OnStart method does not execute. – Semyon Jun 10 '11 at 07:25
  • Do you have in your service class a static ctor or any static fields with field initializer expressions, which might be throwing exceptions or taking a long time when the class is being loaded? – Chris Dickson Jul 01 '11 at 11:53
  • Service class has no static constructors or fields, logging is realised with static class, but I'm really sure that exception handling implemented there very accurate and no deadlocks can occure on logger class init and its methods calls. – Semyon Jul 04 '11 at 14:21

3 Answers3

1

Finally, reporting an answer, that microsoft support helped to get:

This problem occurs because a .NET Framework 2.0 managed assembly that has an Authenticode signature takes longer than usual to load. The signature is always verified when the .NET Framework 2.0 managed assembly that has an Authenticode signature is loaded.

Additionally, the .NET Framework 2.0 managed assembly may take longer than usual to load because of various other settings. For example, the .NET Framework 2.0 managed assembly may take longer than usual to load because of the network configuration.

Here is Microsoft KB, that describes problem and provides hotfix to .NET Framework 2.0 But this hotfix does not fix the long load time problem, but adds ability to simply disable disable signature verification in .NET :) by setting generatePublisherEvidence parameter in app.config! Note: if you have .NET Framework SP2 then hotfix is not needed, simply set generatePublisherEvidence parameter in app.config.

http://support.microsoft.com/kb/936707 - FIX: A .NET Framework 2.0 managed application that has an Authenticode signature takes longer than usual to start.

To solve issue, you can use this configuration setting to disable signature verification in a .NET Framework 2.0 managed application. You can use this configuration setting in an application configuration file. To do this, add the following code to the .exe.config file for the .NET Framework 2.0 managed application:

<configuration>
    <runtime>
            <generatePublisherEvidence enabled="false"/>
        </runtime>
</configuration>

If your application is hosted in IIS, change one of the following: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet.config C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config

Note: On x64 machines, you must also change one of the following: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet.config C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG\machine.config

Semyon
  • 31
  • 1
  • 9
0

When the service runs without a problem on win 7 / vista then i think the problem is your code e.g. your OnStart() Method. Normally IO-Operations are not allowed in this method and be careful using threads in this method.

CubaLibre
  • 375
  • 1
  • 2
  • 14
0

You should not declare any resources in the constructor of the service which are going to be used in the OnStart() method of the service. Basically, Constructor runs for the very first time then it holds the values to be used in the OnStart() but then after OnStop() the resources are released and then the same cant be used again. Just move all the instantiation code form the constructor to the OnStart() and It will run.

Here's a link from MSDN for your quick reference: http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.onstart.aspx

There could be one more issue in this. You could be using the debug build. Services dont run in the debug mode so You should use the release build in order to run the service.

Jatin Sehgal
  • 956
  • 2
  • 17
  • 37
  • "There could be one more issue in this. You could be using the debug build. Services dont run in the debug mode so You should use the release build in order to run the service." Where is this information from, dude? – Semyon Jul 04 '11 at 11:53
  • "You should not declare any resources in the constructor of the service which are going to be used in the OnStart() method of the service. Basically, Constructor runs for the very first time then it holds the values to be used in the OnStart() but then after OnStop() the resources are released and then the same cant be used again. Just move all the instantiation code form the constructor to the OnStart() and It will run." Please, read the question carefully: "I've inserted logging to one of services and investigated that problem is outside our code. No single line of code executed." – Semyon Jul 04 '11 at 11:59
  • The two issues I have mentioned in my answer are the two most common problems faced while dealing with the windows services. If you can post your OnStart() and the constructor's code then I might be in a better position to substantiate my answer. I have already given a link to support the first issue while the second issue I mentioned came from my past experience while resolving 1053. – Jatin Sehgal Jul 05 '11 at 07:08
  • Jatin, thank you for help! I'll try to collect test solution, but the problem is that I can't reproduce the behaviour on my environment. New interesting information: customer allowed Internet connection on the server machine (on some standalone proxy server) and services began to start ok; when customer denies Internet connection - problem returns. – Semyon Jul 05 '11 at 10:32
  • Try one thing : insert all the code of OnStart() method into a try block and catch the error in a log file then we might get a better idea. – Jatin Sehgal Jul 05 '11 at 13:29
  • Finnally, I reproduced the problem (maybe similar problem). I've got new machine, didn't connected to the network, installed Windows Server 2003 Standard x86 R2 with SP2 EN on it and installed our setup. On machine startup all .NET services failed with 1053 error. Then I disabled all my .net services except one and commented all code in OnStart method (looging too) - the service did not start with 1053 error too. When I start service manually it runs with no problem after some time after Windows boot. If I connect network cable to the machine - service starts on machine startup. – Semyon Jul 05 '11 at 21:06
  • Suppose service 'A' is not running. Look out for A running on other systems on your local network. Remove & uninstall A from all the systems on the network. I know its tedious & you will suspect this answer but I have experienced it. I had wasted my so many days on 1053 – Jatin Sehgal Jul 06 '11 at 10:38
  • I've asked the technical support from Microsoft and we are working on this issue now. I'll report any result when it be. – Semyon Jul 13 '11 at 09:38