473,699 Members | 2,385 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make a Service fail, so I can see it restart?

Is there a way to write a Service so that it will fail? I'm working
on a Service written in VB.Net, that supports an application we are
building, and I want to make sure that it can restart itself. This
is my first experience with it. In the Service Control Manager I
know there are the options to say what to do if it fails, obviously I
want to select Restart the Service. But how to test it? I can kill
the Service there, but it does not restart. I presume Windows knows
that it was stopped on purpose, rather than failing. I also tried a
little app that called ServiceControll er.Stop() on the Service, and
that also did not work. Again I presume Windows saw that as a Stop
order, not a failure.

Someone suggested throwing an unhandled Exception, but I cant get that
to work. I tried putting in a thread that slept for a while and then
threw the Exception, but it seems to only exit the method and not
kill the Service. So then I put the Exception into the OnStart
method itself, and what happened was that when I started the Service
in the Service Control Manager, it immediately stopped and put up a
MessageBox saying the Service "started and then stopped. Some
services stop automatically if they have no work to do ..."

Also, I wonder if there is a property in the ServiceInstalle r where I
can tell it to set itself for those "Restart the Service" options. I
see how to set it to start Automatically, but I don't see the others
available.

Thanks
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #1
0 1486

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

Similar topics

6
3802
by: Leonardo Curros | last post by:
Hello, I would like to know what's the best way to restart one service. I would like to do it from the service itself. Is this possible? I try it with ServiceController.stop() ServiceController.WaitForStatus(ServiceControllerStatus.Stopped) ServiceController.start() but doesn´t works. It seems waitforstatus instruction is the last
17
6438
by: UJ | last post by:
Is there any way for a windows service to start a windows program ? I have a service that will need to restart a windows app if it needs to. TIA - Jeff.
1
3696
by: Sergey Krutous | last post by:
Can you please help me to resolve the following issue: I developed a windows service. At start up (I have overriden OnStart method) it connects to a web service and if the connection fails the windows service sets ExitCode property to non-zero value (55) and calls Stop method. If this happens when user starts the service in Services snap-in SCM shows error massage and service stops - it's OK. I configured automatic startup and Recovery...
6
5930
by: Ian Boyd | last post by:
Every time during development we had to make table changes, we use Control Center. Most of the time, Control Center fails. If you try to "undo all", it doesn't, and you end up losing your identity seed, or your constraints, or your triggers, or your table. Talking to developers at other companies who have had the misfortune of using DB2, they are adamant that you cannot use the tools; they are buggy and you just have to resign yourself to...
5
6489
by: marccruz | last post by:
Hi, I am writing a Windows Service in C#. I want to gracefully fail the "protected override void OnStop()" function. To do this, I first tried throwing an Exception in the function. However, that left the Service in a "Stopping" state. I would like to fail the Service in the OnStop function without putting the service in the Stopping state. It would be nice if it's still in the Started state. Is this possible? If so, how?
4
2901
by: Jianwei Sun | last post by:
Hi, all, I have a question, and I hope to get some hints here.. I created a really simple service just to check why the service manager doesn't start my service the second time if the first time failed.. I created an atl service through the wizard, and the only thing I do is override the PreMessageLoop()...
6
1337
by: A Marlow | last post by:
Hello, I am new to this game so please bear with me. I have just written a simple application as a service using Visual Studio and managed C++. I wish the process to run in the background and to not use a GUI **ever**. It just runs. And if it fails for ANY reason then it is simply to be restarted. I need some help with this please. I have already found about _CrtSetReportMode and how I need to call it to suppress the popups I would...
0
3146
by: Temporary | last post by:
C# Web Service in IIS Stops Connecting to Oracle (via ADO.NET) Over Time I have a Web Service, written in C#, published on a Windows XT Web Server under IIS, which repeatedly connects to an Oracle 9x database via ADO, processes, disconnects from the database, and exits. The Web Service is triggered by our Tibco messaging system; in our test environment, it is
9
3471
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...
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9172
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
9032
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
8908
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
7745
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 project—planning, coding, testing, and deployment—without 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...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2008
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.