473,404 Members | 2,137 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,404 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 2214
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Mike | last post by:
I want to create a windows service that will monitor another window service. what i need for the service to do is, if a service is stopped I need it to start the service back up example: ...
9
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service...
4
by: Shawn Meyer | last post by:
A windows service that I developed is crashing unexpectedly. All the logging/ tracing that I implemented cannot seem to catch the crash. I am using multiple threads in many different areas. In...
4
by: Lenny Shprekher | last post by:
Hi, I have long time ago written windows service (VS2002) which is working fine on Windows 2000 server for 4 years. After installing service on Windows 2003 SP1 service crashing every time with...
4
by: minoad | last post by:
I have written a program that runs perfectly. I converted this to a service. Upon starting the service, it will stay indefinantly on "Starting" and never move to "Started". The wierd thing here...
2
by: andrewbb | last post by:
Occasionally I had been getting a 30-60 second delay when starting a Windows service written in .NET. Today I stumbled upon a way to reproduce it without fail: Set the system date to the 31st...
5
by: eliasen | last post by:
Hi I have created a Windows Service using C# and .NET2.0. The service is quite simple - right now it doesn't do anything except throwing an exception in the OnStart method. It used to something...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.