Created a real simple C# Window Service that when you ‘Start' on some
machines it will startup within 2-3 seconds.
On other machines, ‘Start' will time out (Error 1053). On the
machines it times out on if you try to ‘Start' it over and over,
usually on the 2nd or 3rd iteration (sometimes as many as 4) it will
finally Start.
I even went to the level of gutting everything out of the OnStart
method, and still encounter the same results. Starts up in 2-3
seconds on some machines, whereas others it will still continue to
Time out with Error 1053.
I tried adding an EventLog.WriteEntry as the very first line of code
in the OnStart and on the machines that time out, this never even gets
executed.
All machines have the latest framework and service pack, as well as
all the system updates from the Windows Update that are available
online.
Any idea how to patch these servers that time out a lot instead of
starting the C# Window Service?
My biggest concern is when Server Admins reboot these machines for
whatever reason that my services will not startup and will require
somebody to babysit them until start up. =/
Let me know if you need further help.
--
Thanks and Regards
Sreejumon
"Cider123" <cide...@hotmail.com> wrote in message
news:5556c5be.02080...@posting.google.com...
the Service Control Manager expects that the services do all their
initialization stuff in about 20 seconds or less, if I recall correctly.
Incase they are n't able to do so, or are in a deadlock simply because their
thread is waiting for a resource being used by another one, then they will
timeout.
The bottomline is that you shouldn't have any heavy duty
initialization/processing during the service's initialization.
--
"French is the language of love, C# is for everything else..."
Kumar Gaurav Khanna
Early Achiever MCSE Windows 2000, MCSE NT 4.0, MCP+I
WWW: http://www.wintoolzone.com/
Email: gau...@wintoolzone.com
"Cider123" <cide...@hotmail.com> wrote in message
news:5556c5be.02080...@posting.google.com...
> > I even went to the level of gutting everything out of the OnStart
> > method, and still encounter the same results.
I checked that out, unfortunately on some machines it will run just
fine while others it will not. All of which are running Windows 2000.
The article suggests that it waits 3 minutes, when in reality it will
fail within about 30 seconds.
In C#, if you create a new project, window service, and compile it and
then try to start this service you will still get the results I speak
of.
On some machines it starts up in 2-3 seconds, whereas others I get the
Error 1053.
All machines have the latest service packs and updates. The only
thing that could differ on the machines are the hardware that they are
comprised of.
I'd find it really odd that an NT Service is dependant upon the
hardware installed in a specific machine.
I can use the VB6 methology of creating an NT Service using the
NTSvc.OCX and it runs smooth as water on any machine.
It's only when creating these services with C# that I'm encountering
this on some machines.
cide...@hotmail.com (Cider123) wrote in message news:<5556c5be.02080...@posting.google.com>...
> > Why don't you post the code so that we can have a look, and
> > try to ascertain what is the issue ?
>
> >> In C#, if you create a new project, window service, and compile it
> and
> then try to start this service you will still get the results I speak
> of.
>
> For the simplistic approach, there really is no code that needs to be
> analyzed. It's the wizard driven generated code, nothing more,
> nothing less.
>
> As previously mentioned, on some machines this "empty" shell of a
> service will start within 2-3 seconds whereas on other machines it
> times out.
>
> I understand the fact if the system does not get a return from the
> Start in a timely fashion that it will time out, but the fact of the
> matter is on the machines that are timing out the Start never gets
> called (or so it appears).
>
> It's as if the Service Control Manager can't even initialize the NT
> Service written in C#.
>
> The following is what is added to the System Log using the Event
> Viewer:
>
> ==========
> System Log
> ==========
>
> Source: Service Control Manager
> Category: None
> Event ID: 7009
>
> Description:
> Timeout (30000 milliseconds) waiting for the <Service> service to
> connect.
>
>
> Source: Service Control Manager
> Category: None
> Event ID: 7000
>
> Description:
> The <Service> service failed to start due to the following error:
> The service did not respond to the start or control request in a
> timely fashion.
>
>
> If you want the source code, simply create a new project in C# and
> make it a window service and try to compile it. Simple. That will
> create the source code (by the wizard) that I'm using for this little
> example.
>
> Runs fine on some servers, while others it will cause these timeouts.
> =\
>
> Any help appreciated. Thanks
Does anyone know about how to resolve?
While starting windows service developed using C# on windows 2000 I
get an error "Error 1053: The service did not respond to the start or
control request in a timely fashion"
I am doing following steps.
1. Compile sample 'Simple service' provided with .NET framework.
(Sample is available at
FrameworkSDK\Samples\QuickStart\howto\samples\services\serviceapplication\simpleservice\cs)
2. Install service using InstallUtil
3. Start service from services
I get same error with all the samples available on web.
Just with simple code with no overlodaed methods, I get the same
problem.
Here is the code. Note that base class OnStart doesn't really do any
thing but I should see service is running through service manager.
MyService.cs
using System;
using System.ServiceProcess;
using System.Diagnostics;
using System.Timers;
public class MyService: ServiceBase {
protected Timer timer;
public static void Main() {
try
{
ServiceBase.Run(new MyService());
}
catch (Exception e)
{
Console.WriteLine("Generic Exception Handler: {0}",
e.ToString());
}
}
public MyService()
{
CanPauseAndContinue = true;
ServiceName = "My Service";
}
}
MyInstaller.cs
using System;
using System.Collections;
using System.Configuration.Install;
using System.ServiceProcess;
using System.ComponentModel;
[RunInstallerAttribute(true)]
public class ProjectInstaller: Installer{
private ServiceInstaller serviceInstaller;
private ServiceProcessInstaller processInstaller;
public ProjectInstaller(){
processInstaller = new ServiceProcessInstaller();
serviceInstaller = new ServiceInstaller();
// Service will run under system account
processInstaller.Account = ServiceAccount.LocalSystem;
// Service will have Start Type of Manual
serviceInstaller.StartType = ServiceStartMode.Manual;
serviceInstaller.ServiceName = "My Service";
Installers.Add(serviceInstaller);
Installers.Add(processInstaller);
}
}
makefile
#
# Makefile
#
_CS_EXE_FLAGS=/t:winexe
_IMPORTS=/r:System.dll /r:System.Configuration.Install.DLL
/r:System.ServiceProcess.DLL
all: MyService.exe
clean:
-@erase MyService.exe
-@erase MyService.pdb
MyService.exe: *.cs
csc $(_CS_EXE_FLAGS) /out:$@ $(_IMPORTS) MyService.cs
MyInstaller.cs
"Kumar Gaurav Khanna" <gau...@wintoolzone.com> wrote in message news:<u5CTvAFPCHA.1972@tkmsftngp11>...
I'm also stuck with problem described in this thread. I've got a C#
service which will never start at a first attempt, a second attempt
starts the service correctly. I'm quite convinced that the reason is
not my code (I use a timer launch of a new thread to ensure that the
service can start within 30 secs) but that it has something to do with
my machine (winxp pro sp1, Net 1.1). I've tried putting logging in my
service class constructor and main method, but these lines of code are
never reached when the service won't start. This makes me think that
there's some kind of problem in the service manager when it needs to
start .Net based services. Another thing I've discovered is the
following event error whenever de service doesn't start:
<snippet>
Event Type: Error
Event Source: Perflib
Event Category: None
Event ID: 2002
Date: 7/01/2005
Time: 9:26:02
User: N/A
Computer: RLS02WP192
Description:
The open procedure for service "WmiApRpl" in DLL
"C:\WINDOWS\System32\wbem\wmiaprpl.dll" has taken longer than the
established wait time to complete. There may be a problem with this
extensible counter or the service it is collecting data from or the
system may have been very busy when this call was attempted.
</snippet>
I don't know it this error is the cause of result of my problem?
Any ideas how to solve this. I've spent already a lot of time googling
on this one, but without positive result.
Regards,
Bert