473,414 Members | 1,703 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,414 software developers and data experts.

Windows Service startup failure

Jon
Hi there

I've written a windows service that works OK, apart fom the fact that if it were to fail during startup, I'm not sure of the best way to handle it. If I let the exception fall thru' from my OnStart() method, the exception is reported in the event log and the service is not marked as started. But the exception message is messy and I want to catch it and report it cleanly if I can. If I catch it myself, report it then continue (without re-throwing), the service is marked as started, which isn't what I want.

Is there any way I can catch the exception for reporting myself, then indicate to the SCM that it hasn't started, without relying on 'fall through' exceptions to inidictate this?

Thanks

Jon

Jul 21 '05 #1
1 1456
You should be able to catch the exception in your OnStart method, process
accordingly, and then throw the same exception or a new less messy exception
for the SCM to deal with.

"Jon" <an*******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
Hi there

I've written a windows service that works OK, apart fom the fact that if it were to fail during startup, I'm not sure of the best way to handle it.
If I let the exception fall thru' from my OnStart() method, the exception is
reported in the event log and the service is not marked as started. But the
exception message is messy and I want to catch it and report it cleanly if I
can. If I catch it myself, report it then continue (without re-throwing),
the service is marked as started, which isn't what I want.
Is there any way I can catch the exception for reporting myself, then indicate to the SCM that it hasn't started, without relying on 'fall
through' exceptions to inidictate this?
Thanks

Jon

Jul 21 '05 #2

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

Similar topics

4
by: Keith | last post by:
I'm in the same boat as the fellow who posted this message back in August: Title : Windows Service, How does one make a service "fail" properly? Author : Ross Bennett Group :...
3
by: Nathan Kovac | last post by:
I have a feeling I am missing something simple, but I just can't find it. Perhaps someone can give me a lead on where to look. I will describe the issue then post my code to the web service. My...
3
by: Amjad | last post by:
Hi, I just wrote a test Windows Service that creates a text file on startup (please see my code below). The file is never created. Protected Overrides Sub OnStart(ByVal args() As String) Dim...
1
by: Jon | last post by:
Hi there I've written a windows service that works OK, apart fom the fact that if it were to fail during startup, I'm not sure of the best way to handle it. If I let the exception fall thru' from...
4
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
4
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... Following the samples online, we implemented a windows service in .Net. Like most services, there's a worker thread actually doing stuff in the background. The problem we've run into is...
1
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... After I installed my .net windows service, I tried to control some of the behavior with the Start Parameters: in the services control parameter. I can put a value in the box but for some...
0
by: =?Utf-8?B?U3RldmUgTWFydGlu?= | last post by:
I am attempting to launch a console application from a service under a different set of credentials running on Windows Server 2003. I am getting an error "0xC06D007E: Module not found." from the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.