By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,220 Members | 1,542 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,220 IT Pros & Developers. It's quick & easy.

Windows Service crashing upon starting

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.