473,320 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

.NET based services not starting reliably: ServiceController.Start() method

We're using the ServiceController class provided by the .NET Framework,
programming in C#. We are using the Start() method to start a service from
another service. This works fine most of the time, but occasionally after a
system startup (where the service doing the starting of the other is
automatically started by Windows XP) the ServiceController's Start() method
fails to start the other service. It is probably throwing an
InvalidOperationException in these cases (we know it is in some cases). Is
there any way to tell why Windows cannot start the service, and are there
known problems with the reliability of the Start() method? It works most of
the time, but occasionally after unsealing the XP OS, or after a restart,
this fails. We're trying retries of calls to the Start() method, but after
3 retries it still fails inexplicably.

We need to find out if:

1.. this is a known problem
2.. how long does it wait, and is this wait time adequate?
3.. can this happen if one of the services upon which the service being
started depends takes too long to start? We are quite sure the actual
service being started takes almost no time to execute its two lines that
consist of starting a worker thread in its OnStart() method.
4.. is there some reason this would only occur after an unseal or system
restart (that's the only time we see it)?
5.. there are any known fixes or workarounds to this problem
Feb 22 '06 #1
6 4141
Arnie wrote:
5.. there are any known fixes or workarounds to this problem


It depends on the nature of the second service and what resources it
requires.

So, what might be happening is that the OS and all it's services are not
fully up, or loaded into memory, or else in the process of loading and
accessible but very slow.

I would advise, if possible, adding a Timer interval of say 30s-60s if you
can afford that to insure that the OS is fully loaded.
Feb 22 '06 #2
If your into Debugging Tools for Windows
(http://www.microsoft.com/whdc/devtoo...g/default.mspx) you can use
Global Flags to set the executable's start up program to WinDbg (don't use a
managed code debugger, it won't work). Set winDbg to beak on first chance
CLR exceptions, then continue the service under the debugger. Also, the
service has to be allowed to interact with the desktop. Be quick because you
must continue the debugger in the service's start up time period (30
seconds?).
--
David Douglass
MCSD for Microsoft .NET
"Arnie" wrote:
We're using the ServiceController class provided by the .NET Framework,
programming in C#. We are using the Start() method to start a service from
another service. This works fine most of the time, but occasionally after a
system startup (where the service doing the starting of the other is
automatically started by Windows XP) the ServiceController's Start() method
fails to start the other service. It is probably throwing an
InvalidOperationException in these cases (we know it is in some cases). Is
there any way to tell why Windows cannot start the service, and are there
known problems with the reliability of the Start() method? It works most of
the time, but occasionally after unsealing the XP OS, or after a restart,
this fails. We're trying retries of calls to the Start() method, but after
3 retries it still fails inexplicably.

We need to find out if:

1.. this is a known problem
2.. how long does it wait, and is this wait time adequate?
3.. can this happen if one of the services upon which the service being
started depends takes too long to start? We are quite sure the actual
service being started takes almost no time to execute its two lines that
consist of starting a worker thread in its OnStart() method.
4.. is there some reason this would only occur after an unseal or system
restart (that's the only time we see it)?
5.. there are any known fixes or workarounds to this problem

Feb 22 '06 #3
in VS 2005 IDE, load up the Service project/solution -- then start the
service, then in VS 2005 "attach to process" -- find your service EXE in the
list of running processing and click "Attach" button -- now place
breakpoints where you think you might need them -- stop your service and
start the service and see if it traps your error -- if this only happens at
system startup, then you'll need to have your service output to EventLog at
approprioate points in the code so you can see where and why it is breaking
(the old fashion way of debugging before we even had debuggers).

you may also want to look into how the service was installed -- did you
specify .NET framework and/or other services as dependant service? You can
do this manually or you can do it via the Windows Installer 3.0 that comes
with VS 2005.

Rob.

"Arnie" <je*****************@msn.com> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl...
We're using the ServiceController class provided by the .NET Framework,
programming in C#. We are using the Start() method to start a service
from another service. This works fine most of the time, but occasionally
after a system startup (where the service doing the starting of the other
is automatically started by Windows XP) the ServiceController's Start()
method fails to start the other service. It is probably throwing an
InvalidOperationException in these cases (we know it is in some cases).
Is there any way to tell why Windows cannot start the service, and are
there known problems with the reliability of the Start() method? It works
most of the time, but occasionally after unsealing the XP OS, or after a
restart, this fails. We're trying retries of calls to the Start() method,
but after 3 retries it still fails inexplicably.

We need to find out if:

1.. this is a known problem
2.. how long does it wait, and is this wait time adequate?
3.. can this happen if one of the services upon which the service being
started depends takes too long to start? We are quite sure the actual
service being started takes almost no time to execute its two lines that
consist of starting a worker thread in its OnStart() method.
4.. is there some reason this would only occur after an unseal or system
restart (that's the only time we see it)?
5.. there are any known fixes or workarounds to this problem

Feb 22 '06 #4
thanks for the reply. We'll look into delaying things a bit to see if that
helps.

We only see the issue after many power cycles.

So our fix is taking the form of:
-delay a bit and try again
-catch an exception if the second service doesn't start and retry
-lastly force a reboot of the system

-jeff

"John Bailo" <ja*****@texeme.com> wrote in message
news:2_********************@speakeasy.net...
Arnie wrote:
5.. there are any known fixes or workarounds to this problem


It depends on the nature of the second service and what resources it
requires.

So, what might be happening is that the OS and all it's services are not
fully up, or loaded into memory, or else in the process of loading and
accessible but very slow.

I would advise, if possible, adding a Timer interval of say 30s-60s if you
can afford that to insure that the OS is fully loaded.

Feb 23 '06 #5
thanks for the reply. Since we see this so infrequently (like once in 100
powercycles) we would like to only trap it when it fails. Starting the
second service will throw an exception on a fail so it looks like this would
help.

What we would really like is for MS to fix this?

-jeff

"David Douglass" <Da***********@discussions.microsoft.com> wrote in message
news:B8**********************************@microsof t.com...
If your into Debugging Tools for Windows
(http://www.microsoft.com/whdc/devtoo...g/default.mspx) you can
use
Global Flags to set the executable's start up program to WinDbg (don't use
a
managed code debugger, it won't work). Set winDbg to beak on first chance
CLR exceptions, then continue the service under the debugger. Also, the
service has to be allowed to interact with the desktop. Be quick because
you
must continue the debugger in the service's start up time period (30
seconds?).
--
David Douglass
MCSD for Microsoft .NET
"Arnie" wrote:
We're using the ServiceController class provided by the .NET Framework,
programming in C#. We are using the Start() method to start a service
from
another service. This works fine most of the time, but occasionally
after a
system startup (where the service doing the starting of the other is
automatically started by Windows XP) the ServiceController's Start()
method
fails to start the other service. It is probably throwing an
InvalidOperationException in these cases (we know it is in some cases).
Is
there any way to tell why Windows cannot start the service, and are there
known problems with the reliability of the Start() method? It works most
of
the time, but occasionally after unsealing the XP OS, or after a restart,
this fails. We're trying retries of calls to the Start() method, but
after
3 retries it still fails inexplicably.

We need to find out if:

1.. this is a known problem
2.. how long does it wait, and is this wait time adequate?
3.. can this happen if one of the services upon which the service being
started depends takes too long to start? We are quite sure the actual
service being started takes almost no time to execute its two lines that
consist of starting a worker thread in its OnStart() method.
4.. is there some reason this would only occur after an unseal or
system
restart (that's the only time we see it)?
5.. there are any known fixes or workarounds to this problem

Feb 23 '06 #6
thanks for the input, this is helpful.

We know that the secondary service simply fails to start, and it happens
very infrequently.
After 10's of power cycles.

Any idea if doing an umanaged service is more reliable?

-jeff

"Rob R. Ainscough" <ro*****@pacbell.net> wrote in message
news:Oz****************@TK2MSFTNGP09.phx.gbl...
in VS 2005 IDE, load up the Service project/solution -- then start the
service, then in VS 2005 "attach to process" -- find your service EXE in
the list of running processing and click "Attach" button -- now place
breakpoints where you think you might need them -- stop your service and
start the service and see if it traps your error -- if this only happens
at system startup, then you'll need to have your service output to
EventLog at approprioate points in the code so you can see where and why
it is breaking (the old fashion way of debugging before we even had
debuggers).

you may also want to look into how the service was installed -- did you
specify .NET framework and/or other services as dependant service? You
can do this manually or you can do it via the Windows Installer 3.0 that
comes with VS 2005.

Rob.

"Arnie" <je*****************@msn.com> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl...
We're using the ServiceController class provided by the .NET Framework,
programming in C#. We are using the Start() method to start a service
from another service. This works fine most of the time, but occasionally
after a system startup (where the service doing the starting of the other
is automatically started by Windows XP) the ServiceController's Start()
method fails to start the other service. It is probably throwing an
InvalidOperationException in these cases (we know it is in some cases).
Is there any way to tell why Windows cannot start the service, and are
there known problems with the reliability of the Start() method? It
works most of the time, but occasionally after unsealing the XP OS, or
after a restart, this fails. We're trying retries of calls to the
Start() method, but after 3 retries it still fails inexplicably.

We need to find out if:

1.. this is a known problem
2.. how long does it wait, and is this wait time adequate?
3.. can this happen if one of the services upon which the service being
started depends takes too long to start? We are quite sure the actual
service being started takes almost no time to execute its two lines that
consist of starting a worker thread in its OnStart() method.
4.. is there some reason this would only occur after an unseal or system
restart (that's the only time we see it)?
5.. there are any known fixes or workarounds to this problem


Feb 23 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chakkaradeep | last post by:
hi all, as it was discussed earlier in this forum titled,"Execution of Another Application in Services", i got the answer that Services are not meant for executing another applications, but...
3
by: Yves Royer | last post by:
Hi all, I have a little question about Windows Services. For my app i need 3 different Windows Services, each with its own functionality. I'm trying to make a test service to see what happens...
0
by: Doug Bailey | last post by:
I am trying to control a Windows Service via a Web Service interface. (I am developing in .NET2003) I am using the ServiceController object which allows me to read the state of the services with...
1
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. I'm having trouble getting the code that I've written to work, can anyone shed some light as to where I'm...
4
by: Christoph Duesmann | last post by:
Hi ! I wan't to code a service which will be installed on some clients in our network. The service should have the following features : - Scan all properties of the Client (Hardware, Software...
2
by: VBTricks.de.vu Webmaster | last post by:
Hello, I'm trying to speed up windows start a bit. Therefore I want to start some services at a later point of time and some only if I run the application which needs the services. The first...
1
by: Przemo | last post by:
Is it possible to start or stop a windows service from ASP.NET 2.0? Some examples? thanks Przemo
2
by: sdstraub | last post by:
I have created 5 services in my project, in the 1st service I set servicestorun = array of all 5 services, I have a project installer with 5 service installers, one for each service. I have code...
3
by: rkausch | last post by:
Hello, I'm performing some research to determine the feasibility of developing a Windows Service (see http://en.wikipedia.org/wiki/Windows_Service for the specific definition of "service" to which...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.