473,785 Members | 2,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

restarting windows service from my application

Hello,

I am working on a .Net application (aspx+webservic es) that uses a
windows service I created too.
Sometimes, the exe linked to my service crashes (mostly runtime
exception), and as a consequence my application can not work. I coult
not catch or controle those exceptions, so my application needs to be
able to restart my service when it does not answer animore.
Does anyone knows how to do that?
My application is in C#. I work with VS .NET, and I have a solution
containing many projects including my application project an my windows
service project.

Any help woulf be welcome!
regards,
G.

May 18 '06 #1
13 5342
Hi,

"ghighi" <gh************ ***@free.fr> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
Hello,

I am working on a .Net application (aspx+webservic es) that uses a
windows service I created too.
Sometimes, the exe linked to my service crashes (mostly runtime
exception),
I suggest you to see what makes it crash in the first place.

My application is in C#. I work with VS .NET, and I have a solution
containing many projects including my application project an my windows
service project.


See the ServiceControll er class, you can control a service with it.
You may need extra privilegies for using it though.

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
May 18 '06 #2
On 17 May 2006 23:59:37 -0700, "ghighi" <gh************ ***@free.fr>
wrote:
Hello,

I am working on a .Net application (aspx+webservic es) that uses a
windows service I created too.
Sometimes, the exe linked to my service crashes (mostly runtime
exception), and as a consequence my application can not work. I coult
not catch or controle those exceptions, so my application needs to be
able to restart my service when it does not answer animore.
Does anyone knows how to do that?
My application is in C#. I work with VS .NET, and I have a solution
containing many projects including my application project an my windows
service project.

Any help woulf be welcome!
regards,
G.

Hi G

you could use the IADsService interface which is part of Active
Directory, look here
http://msdn.microsoft.com/library/de...adsservice.asp
or you could use the WMI Win32_Service methods

http://msdn.microsoft.com/library/de...32_service.asp

Hope this helps

cherrs

Steve

http://pretty-vacant.co.uk
May 18 '06 #3
Hello,
thanks for your help.

The problem is that My exceptions are unexpected,
hardly/un-reproducible and I can not catch or control them.

I tried to use servicecontroll er class; it seems good (I can get my
service status for example) but I can not start or stop my service...
what kind of privilegies do I need to use it? where do I configure it?

thx,
G.

May 18 '06 #4
Hi,

"ghighi" <gh************ ***@free.fr> wrote in message
news:11******** **************@ j55g2000cwa.goo glegroups.com.. .
Hello,
thanks for your help.

The problem is that My exceptions are unexpected,
hardly/un-reproducible and I can not catch or control them.
Well , you need a better logging planning, I strongly encourage you to find
the source of this exceptions
I tried to use servicecontroll er class; it seems good (I can get my
service status for example) but I can not start or stop my service...
what kind of privilegies do I need to use it? where do I configure it?


IIRC only members of Administrator can do so. Dangerous proposition to give
admin priviledges to an asp.net app
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
May 18 '06 #5
Hi,

"
Hi G

you could use the IADsService interface which is part of Active
Directory, look here
http://msdn.microsoft.com/library/de...adsservice.asp
or you could use the WMI Win32_Service methods

http://msdn.microsoft.com/library/de...32_service.asp


The framework provide a way for doing this, ServiceControll er class
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
May 18 '06 #6

"ghighi" <gh************ ***@free.fr> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
| Hello,
|
| I am working on a .Net application (aspx+webservic es) that uses a
| windows service I created too.
| Sometimes, the exe linked to my service crashes (mostly runtime
| exception), and as a consequence my application can not work. I coult
| not catch or controle those exceptions, so my application needs to be
| able to restart my service when it does not answer animore.
| Does anyone knows how to do that?
| My application is in C#. I work with VS .NET, and I have a solution
| containing many projects including my application project an my windows
| service project.
|
| Any help woulf be welcome!
| regards,
| G.
|

Your "Service" shouldn't be a Windows service in the first place, years ago
MSFT introduced COM+ just for this. It should be used whenever you needed
secure and restartable services (amongst other services like threading,
object pooling, transactions etc..). Services where invented for NT4 long
before COM+ was introduced, stay away from Windows services on anything
higher than NT4, use Component services, they are more flexible and much
easier to configure and control.

Willy.
May 18 '06 #7
On Thu, 18 May 2006 15:00:46 -0400, "Ignacio Machin \( .NET/ C# MVP
\)" <ignacio.mach in AT dot.state.fl.us > wrote:
Hi,

"
Hi G

you could use the IADsService interface which is part of Active
Directory, look here
http://msdn.microsoft.com/library/de...adsservice.asp
or you could use the WMI Win32_Service methods

http://msdn.microsoft.com/library/de...32_service.asp


The framework provide a way for doing this, ServiceControll er class
--


Thanks Ignacio, I'd assumed as much but didn't know the name of the
object to use.
Steve

http://www.pretty-vacant.co.uk
May 18 '06 #8
Well, anyway, if I have properly understood what I have read about how
to give admin priviledges to my app
(see
http://support.microsoft.com/default...87&Product=asp
, if interested) ,
I will need admin login, password, domain etc... what I obviously won't
know, my application being installed on several servers out of my
control

unless you know another way to process ...

May 19 '06 #9
Thanks Willy for your advices; I'll remeber it!
Unfortunatly, the project I work on is not MY baby, I'm just its new
nany.
I work on an existing and ever running on my client's servers
application. Therefore if I can make it come along, I can't completly
change it ... :-(
So I have to make do with it!

May 19 '06 #10

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

Similar topics

3
1911
by: Jerry Boone | last post by:
I have a development unit running XP Pro and I cannot get it to build a web project without restarting IIS. There errors in the task list are.... ! Could not copy temporary files to the output directory ! The file'bin\project1.dll' cannot be copied to the run directory. The process cannot access the file because it is being used by another process. ! The file'bin\project1.pdb' cannot be copied to the run directory. The process...
7
10079
by: Gene | last post by:
I have a Windows Service (VB.NET) that runs 24/7. It queries a Web service 5 to 10 times per hour. About 2 or 3 times a month, it fails. The log indicates that it sends the request to the Web service but there is no return from the service. Stopping and restarting the Windows service cures the problem. Our desire is to cure the problem with appropriate error handling but failing that, is there an easy way to automatically stop and...
2
2171
by: felecha | last post by:
I'm stumped. I'm working on an application in VB.Net that uses System.Messaging.MessageQueue to listen for messages sent to a private queue on a remote machine. Both machines are in the same Workgroup in a small private LAN. The messaging is working fine, but since the remote machine is used as a control system and has to be rebooted when there is a configuration change, I have to handle the remote queue going down and coming back up...
4
15937
by: Simon Verona | last post by:
My software relies on a third party data provider to a propretary database. In turn the third party database relies on a Windows Service that runs on the server to supply the data... The problem is that from time to time this service dies without warning. Is there any way that I can write another small service or similar (using vb.net) that checks at regular intervals that the service is running and restart it if it isn't???
2
1178
by: Stephen | last post by:
Hi, Can some direct me to an article or sample code where we can create an application or a service to restart another windows service? Thanks, Stephen
0
1348
by: Kevin A | last post by:
The problem is that the web application mysteriously shuts down (ending all sessions) due to a supposed 'configuration change'. By using ASP.Net Health Monitoring we can determine that the application occasionally raises a "Application is shutting down. Reason: Configuration changed." event during normal application usage. The only known way to duplicate this event is to manually save the web.config, which correctly triggers the event as...
6
9350
by: sergio.calleja | last post by:
Hi Everybody, i need to restart a windows service made with c# when an fixed event is raised. So to test it, I've added a servicecontroller to my service, and in the creation method, i've created a new thread to try to stop it. This is my code: public Service1() { // This call is required by the Windows.Forms Component Designer.
4
8832
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 how to get the service to exit when the worker thread has a fatal error *and* get the SCM to invoke the auto-restart configuration? The worker thread can error out while the parent thread in the server process chugs along. We can set the exit...
3
4000
by: gourmet | last post by:
Hello! I need to restart the "Windows Audio Service" (audiosrv) via C#. I'm using the ServiceController Class to do this. It is no problem under XP and no problem under vista if UAC is disabled. But with enabled UAC i'm getting a "access refused" exception. I also tried to do it via console with "net start ..." but the same error appears. Three questions:
0
9643
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
9480
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
10315
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...
1
10085
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
9947
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
5379
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...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4045
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.