473,662 Members | 2,536 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows Service - Reporting Error at Start

Joe
C# .NET 2.0

I've got a Windows Service that works exactly as I expect it to. However,
it does rely on a few Configuration settings. If the customer doesn't
configure it correctly, the service shouldn't start.

So I've put in some try...catchs, but what I'm not sure how to do is not
allow the service to start. If attempted to start with the NET START
command, throwing an exception keeps the service from starting, but the
message reported back is :

The MyService service is starting.
The MyService service could not be started.

The service did not report an error.

So how do I report this error? Writing it to the EvenLog doesn't resolve
it, although there is an entry in there as expected.

Secondly, if the service is started via the SMC, the service doesn't start
as expected, but I'm given the following error:

The MyService service on Local Computer started and then stopped. Some
services stop automatically if they have no work to do, for example, the
Performance Logs and Alerts service.

So how do I prevent the service from starting (although in both these
cases, the service doesn't actually start) and make whatever appropriate
error reports necessary?

Thanx!

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Mar 30 '06 #1
6 8688
> I've got a Windows Service that works exactly as I expect it to. However,
it does rely on a few Configuration settings. If the customer doesn't
configure it correctly, the service shouldn't start.


Perhaps, in OnStart you just don't call the base class' OnStart if the
criteria aren't met?

That ought to keep it from starting.
Mar 30 '06 #2
Hi,

IIRC if you throw an exception in the onstart and do not catch it the
service does not start and you get an error msg.

Additionally I would insert a event log with a detailed description of what
happened
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Joe" <js************ *@logicor.com> wrote in message
news:op******** *******@jsheble-laptop.logicorp hx2.com...
C# .NET 2.0

I've got a Windows Service that works exactly as I expect it to. However,
it does rely on a few Configuration settings. If the customer doesn't
configure it correctly, the service shouldn't start.

So I've put in some try...catchs, but what I'm not sure how to do is not
allow the service to start. If attempted to start with the NET START
command, throwing an exception keeps the service from starting, but the
message reported back is :

The MyService service is starting.
The MyService service could not be started.

The service did not report an error.

So how do I report this error? Writing it to the EvenLog doesn't resolve
it, although there is an entry in there as expected.

Secondly, if the service is started via the SMC, the service doesn't start
as expected, but I'm given the following error:

The MyService service on Local Computer started and then stopped. Some
services stop automatically if they have no work to do, for example, the
Performance Logs and Alerts service.

So how do I prevent the service from starting (although in both these
cases, the service doesn't actually start) and make whatever appropriate
error reports necessary?

Thanx!

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Mar 31 '06 #3
Joe
I do have a try...catch (was pretty sure my original message stated as
much). And there are EventLog entries, but it still doesn't perform as
expected...

On Fri, 31 Mar 2006 07:00:15 -0700, Ignacio Machin ( .NET/ C# MVP )
<ignacio.mach in AT <dot.state.fl.u s>> wrote:
Hi,

IIRC if you throw an exception in the onstart and do not catch it the
service does not start and you get an error msg.

Additionally I would insert a event log with a detailed description of
what
happened


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Apr 3 '06 #4
Joe
I found my own answer, and it was something I overlooked. The ServiceBase
class has an ExitCode property. Setting this, and still re-throwing the
exception in the OnStart does what I expect and want it to do.

Thanx!

On Mon, 03 Apr 2006 08:10:27 -0700, Joe <js************ *@logicor.com>
wrote:
I do have a try...catch (was pretty sure my original message stated as
much). And there are EventLog entries, but it still doesn't perform as
expected...

On Fri, 31 Mar 2006 07:00:15 -0700, Ignacio Machin ( .NET/ C# MVP )
<ignacio.mach in AT <dot.state.fl.u s>> wrote:
Hi,

IIRC if you throw an exception in the onstart and do not catch it the
service does not start and you get an error msg.

Additionally I would insert a event log with a detailed description of
what
happened



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Apr 3 '06 #5
Just curious. I have looked everywhere in VS 2005 for the Windows
Service Project Template. I can't find it anywhere. Were you able to
find it?

Apr 3 '06 #6
Joe
if you mean the project wizard within the IDE itself, then yes... if you
mean the physical files that actually make up the template, then no...

On Mon, 03 Apr 2006 11:53:19 -0700, tdavisjr <td******@gmail .com> wrote:
Just curious. I have looked everywhere in VS 2005 for the Windows
Service Project Template. I can't find it anywhere. Were you able to
find it?


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Apr 3 '06 #7

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

Similar topics

0
2093
by: LarryH | last post by:
Hi all, I going thru the MCSD course and I am creating a Windows Service. The Service compiles with no errors and I can install it using "Installutil" with no problem. But when I go into Services and try to start it I get the following error message. "Could not start the RemoteAccessAgent service on Local Computer. Error 193: 0xc1" Does anyone know what this is and how to fix this? Thanks in advance for your reply.
6
13091
by: Ashwin Kambli | last post by:
Hi, I am trying to write a Windows Service application using C#. I wrote a very trivial example (logs messages during Start and Stop events to the evenlog). I have no problem installing it (using installutil.exe). But, when I try to start the service it times out and gives me a "Error: 1053 The service did not respond to the start or control request in a timely fashion." message. Whats strange is that I have no problem starting up this...
2
21889
by: Mark | last post by:
I created an extremely simple windows service that only writes to the EventLogs on Stop and Pause. I installed it using the InstallUtil.exe program, the output of which is below. It appears to be successful. I'm now ready to start my service (I think) but the NET START command does not appear to indicate that the service is available to be run. The output for NET START is below as well. The Services list in the W2K administrator...
3
5723
by: Chuck Bowling | last post by:
Ok, I'm not sure this is a C# question but here goes anyhow... I used this walkthru to create a windows service: ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcon/html/vbwlkwalkthroughcreatingwindowsserviceapplication.htm It appears to install ok but when I try to start it I get this message in a JIT Debugging window: "JIT Debugging failed with the following error: Access is denied.
3
2495
by: mpriem | last post by:
Hi, I am developing my very first Windows Service. I want to query AD every 5 minutes to generate a Report which I will use in a website. I use the following testcode, but the service won't start in a timely fashion. What am I doing wrong? using System; using System.IO;
6
6469
by: uuyytt | last post by:
I have a Windows service from which I want to start Internet Explorer with a particular URL as an argument. I don't know why my code (shown below) doesn't work. I know that IExplore.exe starts as I can see it in my task manager, but it is not visible. Can anyone explain what is happening? My code: Process p = Process.Start("IExplore.exe", m_strURL);
2
9455
by: =?Utf-8?B?Sm9obiBTLg==?= | last post by:
I developed a Windows Service application written in vb.net and have successfully installed it on many workstations (over 25 PCs). All workstations have Windows XP SP2 installed. There are two workstations located at separate customers that have an issue during installation. I receive the error “The service did not respond to the start or control request in a timely fashion.” The service properties Log On is set to use the Local...
9
3469
by: Yasir Zaheer | last post by:
I have made a windows service which is configured to start automatically at the system startup under the USER account type. The service is working perfectly fine when I try to start it manually, but it is unable to start automatically at system restart and following errors are displayed in the Event Logs. 1 - Timeout (30000 milliseconds) waiting for the (Service Name) service to connect. 2 - The (Service Name) service failed to start...
4
9689
by: =?Utf-8?B?am1hZ2FyYW0=?= | last post by:
I've written a .net Windows service in C#. It works most of the time for most people. It is configured to automatically start when Windows boots. Sometimes it fails to start on Windows XP during boot. All I know is that it is timing out. But no useful details appear in the event log, not even my first EventLog message in OnStart. How can I figure out why it isn't starting? How can I fix this? My ServiceBase constructor just sets a few...
0
8344
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8764
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8546
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.