Reputation: 2927
I have a windows service written in C# and installed on my machine by using the installUtil.exe utility. After the installation completes successfully, I am trying to start the service. However it is giving me a 1053 error.
Now the truly weird thing is that when I delete the Config file the service starts just fine (Although then it stops because of a null pointer Exception, which is to be expected since there is no config file).
Any insights on this? I'm at loss here I've installed another service on the same machine which works just fine.
Note: the OS is Windows 7 Home Premium x64
edit =======
To make it clear, I tried logging (using the event Viewer) in the OnStart()
Method. When the log file is deleted I can see all the log entries and the service works fine up to the point where it needs to get data from the config file.
The problem seems to be when the config file is still present. The first line of the OnStart()
Method makes a log entry, HOWEVER, the program is not reaching this point.
edit 2 ========================
protected override void OnStart(string[] args)
{
try
{
this.EventLog.WriteEntry("Starting Focus Stock Service");
This log entry is being logged only if the config file is not present otherwise it will not get to this point.
> <?xml version="1.0"?> <configuration> <appSettings>
> <add key="Directory" value="C:\Logs\FocusCommon"/>
> <add key="FileName" value="log"/>
> <add key="LogLevel" value="3"/>
> <add key="StockRemotingServerPort" value="10001"/>
> <add key="StockRemotingServerName" value="FocusStockServer"/>
> <add key="SQLServerConnStringTemplate" value="server=$server$;uid=$username$;pwd=$password$;database=$database$;MultipleActiveResultSets=True;Pooling=False;"/>
> <add key="AccountingSynchIntervalMinutes" value="1"/>
> <add key="LocalImageDirectory" value="C:\Focus360_Image_Dir"/>
> <add key="LocalBrandImageDirectory" value="C:\Focus360_Image_Dir\Brands"/>
> <add key="LocalAttachmentDirectory" value="C:\Focus360_Attachment_Dir"/>
> <add key="EmailServer" value="maltanet.net" />
> <add key="EmailPort" value="25" />
> <add key="EmailUserName" value="" />
> <add key="EmailPassword" value="" />
> <add key="EmailUseSSL" value="false" /> </appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSS_SQLConnPool" publicKeyToken="40FEE7F833FAA042" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.0.4525.28539" newVersion="1.0.4525.28539"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
Upvotes: 0
Views: 1445
Reputation: 2927
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
Ok so this seemed to be the problem. I'm not entirely sure why this was preventing it from starting on my machine. (Yes I tried on two other machines and the service started just fine !!!)
Anyways I removed this line and the service started on my machine as well.
Upvotes: 1
Reputation: 941465
This is the one thing that can go wrong when you start a service, other than it plain crashing. Your OnStart() method has 30 seconds to finish the job and return. If it takes longer then the service control manager assumes there is something seriously wrong, stops waiting for your service to start and produces error 1053, "The service did not respond to the start or control request in a timely fashion".
You can ask for additional time by calling RequestAdditionalTime(). But some odds that there is something basically wrong with your OnStart() code, 30 seconds is rather a long time to get a service started. Improve the odds to diagnose this problem by improving the logging in your code so you'll know where it gets stuck.
Upvotes: 2