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

Stop Service on Error

Hi

I have developed a Windows service in C# (inherited from System.ServiceProcess.ServiceBase) and, after the service has successfully started, when I catch an exception I'd like to write the code for the service to stop itself. Right now, when an exception occurs the service seems to halt but it still shows as "Started" in the Services window. Could someone please suggest the best way to stop the service so the "Started" doesn't appear

Thanks
Nov 16 '05 #1
1 2447
The simplest solution to this is for your service to create a
ServiceController referring to itself and call its Stop method.
"Mike001" <an*******@discussions.microsoft.com> wrote in message
news:32**********************************@microsof t.com...
Hi,

I have developed a Windows service in C# (inherited from System.ServiceProcess.ServiceBase) and, after the service has successfully
started, when I catch an exception I'd like to write the code for the
service to stop itself. Right now, when an exception occurs the service
seems to halt but it still shows as "Started" in the Services window. Could
someone please suggest the best way to stop the service so the "Started"
doesn't appear?
Thanks

Nov 16 '05 #2

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

Similar topics

5
by: Richard Steele | last post by:
I have created a WinForm application that needs to be run as a windows service (the PC is inaccesible by any user) i have successfully installed the application as a windows service. When i start...
1
by: Murali | last post by:
Hi All, How to control(Start / Stop) a "Windows Service" (written in C#) from a windows application(.exe). Please send any URL/Solution which will guide me to solve this issue. Thanks in...
2
by: Amil | last post by:
Don't answer this unless you know what you are talking about. I want to use ServiceController in my code to start and stop a Windows Service. I do not want to use <impersonate> in my config...
5
by: Stu Carter | last post by:
Hi, ENV: Windows 2003 Server SP1 (+all updates), VS 2003, .Net 1.1 SP1 We've got an ASP.Net web application using State Service. All is fine until we tried to use the app through a virtual...
0
by: Chris Dunaway | last post by:
I wish to write a small application that will allow me to start and stop a windows service on another server. Currently, I have to connect to the server using Remote Desktop Connection and then...
0
by: Stephen | last post by:
Hi, Is there a way to stop Windows service, when the service errors out? Thanks, stephen
1
by: yqyq22 | last post by:
Hi all, Is there a way to stop a service eg. net stop "dns client" without to invoke .bat or .cmd? I didn't find nothing ( no class etc) with google about this. THANKS IN ADVANCE.
3
by: shakthi | last post by:
Failed to stop service. System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.ServiceHost, cannot be used for communication because it is in the...
4
by: rottmanj | last post by:
I have written an application that installs a service and then is supposed to start the service. Everything works great except for the service starting(either with AfterIntall or starting it from the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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?
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
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...

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.