472,146 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Windows Service crashing upon starting

Hey all,

I wrote a Windows Service. When I test it on my developement machine (winXP)
it works fine. It starts ok, never crashes, etc.
When I install the service on another machine (win2000) it *sometimes*
crashes upon starting. The progressbar you get when you manually start the
server will very slowly progress, and when it hits 100% after 2 minutes or
something I get the error 'The service could not be started because it did
not respond in a timely manner' or something like that. No eventvwr error
codes, nothing. The status of the service keeps saying 'starting' and the
funniest thing is, sometimes it actually WILL run in the background (I can
check that because of log files etc). However, I can't stop the service
after that, because the stop / start buttons are grayed out, I can't
terminate the process from the task manager (access denied). And when it
does NOT crash, it keeps running flawlessly until the machine is rebooted,
or I manually terminate it.
So two questions:

- Why does it *sometimes* crash on the win2000 server? It doesn't do any
fancy stuff, just connect to a database, copy some data, etc.
- IF it crashes, is there any way to terminate the service when it stopped
responding? Having to reboot the machine is a pain, especially when the
server uptime is an important thing.

Thank you!

Razzie
Nov 16 '05 #1
2 2119
Hi,

You should always create a new thread in the OnStart() method and let this
method to end , also you should use the EventLog to log any error you get at
the service, believe me it helps a LOT.

probably you are accesing the DB before ends OnStart() hence your
OnStart() takes longer that it should and you get the error.

Do this, on the OnStart() method just create the thread and the event
logger and do all the work on another thread.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Razzie" <ra****@quicknet.nl> wrote in message
news:%2*****************@TK2MSFTNGP12.phx.gbl...
Hey all,

I wrote a Windows Service. When I test it on my developement machine (winXP) it works fine. It starts ok, never crashes, etc.
When I install the service on another machine (win2000) it *sometimes*
crashes upon starting. The progressbar you get when you manually start the
server will very slowly progress, and when it hits 100% after 2 minutes or
something I get the error 'The service could not be started because it did
not respond in a timely manner' or something like that. No eventvwr error
codes, nothing. The status of the service keeps saying 'starting' and the
funniest thing is, sometimes it actually WILL run in the background (I can
check that because of log files etc). However, I can't stop the service
after that, because the stop / start buttons are grayed out, I can't
terminate the process from the task manager (access denied). And when it
does NOT crash, it keeps running flawlessly until the machine is rebooted,
or I manually terminate it.
So two questions:

- Why does it *sometimes* crash on the win2000 server? It doesn't do any
fancy stuff, just connect to a database, copy some data, etc.
- IF it crashes, is there any way to terminate the service when it stopped
responding? Having to reboot the machine is a pain, especially when the
server uptime is an important thing.

Thank you!

Razzie

Nov 16 '05 #2
I will give it a try. Thanks!

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:O2**************@TK2MSFTNGP09.phx.gbl...
Hi,

You should always create a new thread in the OnStart() method and let this
method to end , also you should use the EventLog to log any error you get
at
the service, believe me it helps a LOT.

probably you are accesing the DB before ends OnStart() hence your
OnStart() takes longer that it should and you get the error.

Do this, on the OnStart() method just create the thread and the event
logger and do all the work on another thread.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Razzie" <ra****@quicknet.nl> wrote in message
news:%2*****************@TK2MSFTNGP12.phx.gbl...
Hey all,

I wrote a Windows Service. When I test it on my developement machine

(winXP)
it works fine. It starts ok, never crashes, etc.
When I install the service on another machine (win2000) it *sometimes*
crashes upon starting. The progressbar you get when you manually start
the
server will very slowly progress, and when it hits 100% after 2 minutes
or
something I get the error 'The service could not be started because it
did
not respond in a timely manner' or something like that. No eventvwr error
codes, nothing. The status of the service keeps saying 'starting' and the
funniest thing is, sometimes it actually WILL run in the background (I
can
check that because of log files etc). However, I can't stop the service
after that, because the stop / start buttons are grayed out, I can't
terminate the process from the task manager (access denied). And when it
does NOT crash, it keeps running flawlessly until the machine is
rebooted,
or I manually terminate it.
So two questions:

- Why does it *sometimes* crash on the win2000 server? It doesn't do any
fancy stuff, just connect to a database, copy some data, etc.
- IF it crashes, is there any way to terminate the service when it
stopped
responding? Having to reboot the machine is a pain, especially when the
server uptime is an important thing.

Thank you!

Razzie


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Mike | last post: by
9 posts views Thread by SP | last post: by
4 posts views Thread by Shawn Meyer | last post: by
4 posts views Thread by minoad | last post: by
5 posts views Thread by eliasen | last post: by
5 posts views Thread by dm3281 | last post: by

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.