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
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
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.
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.
精彩评论