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

OnShutdown not executing in Windows service

Restarting Windows seems not to fire the OnShutdown event in the
Windows Service.
Does not work on Windows XP SP2 and not on Windows 2003
Server SP1.

OnStart and OnStop do work fine.

Steps to reproduce:
Create a Windows service in VB.NET using VS 2005.
Set CanShutdown property to true.

Implement
Protected Overrides Sub OnShutdown()
Diagnostics.EventLog.WriteEntry(Me.ServiceName, "Shutdown")
End Sub

Start Service and Reboot.
Dec 22 '05 #1
2 4082
You can't write to the event log during shutdown since the event log itself
is shutting down. Try writing to a file if you want to log something during
shutdown.

"Peter Meinl" <pi*@petermeinl.de> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Restarting Windows seems not to fire the OnShutdown event in the
Windows Service.
Does not work on Windows XP SP2 and not on Windows 2003
Server SP1.

OnStart and OnStop do work fine.

Steps to reproduce:
Create a Windows service in VB.NET using VS 2005.
Set CanShutdown property to true.

Implement
Protected Overrides Sub OnShutdown()
Diagnostics.EventLog.WriteEntry(Me.ServiceName, "Shutdown")
End Sub

Start Service and Reboot.

Dec 23 '05 #2
Good hint.

I expected the OS services shutting down after custom services.
"Stephen Martin" <sm*****@removethis.emsoft.andthis.ca> wrote in message
news:eb**************@TK2MSFTNGP11.phx.gbl...
You can't write to the event log during shutdown since the event log
itself is shutting down. Try writing to a file if you want to log
something during shutdown.

"Peter Meinl" <pi*@petermeinl.de> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Restarting Windows seems not to fire the OnShutdown event in the
Windows Service.
Does not work on Windows XP SP2 and not on Windows 2003
Server SP1.

OnStart and OnStop do work fine.

Steps to reproduce:
Create a Windows service in VB.NET using VS 2005.
Set CanShutdown property to true.

Implement
Protected Overrides Sub OnShutdown()
Diagnostics.EventLog.WriteEntry(Me.ServiceName, "Shutdown")
End Sub

Start Service and Reboot.


Jan 3 '06 #3

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

Similar topics

1
by: Yoshitha | last post by:
HI I am calling exe (vb.net application) from web application for this i wrote code like this system.diagnosis.process.start("e:\...") i wrote above code in button click event.
0
by: Paul Lewis` | last post by:
Hello, I am trying to make a service which will shut a hanging process down. Before the OnShutdown function runs, windows asks if I would like to end the task. I cannot modify the hanging...
7
by: knf | last post by:
For a C# windows service, it seems like the best practice is to only implement OnStop(). Is that correct? Do I only need OnShutdown if I need to take different actions when the server is shutdown?...
3
by: Peter Strøiman | last post by:
Hi. I have a web application that needs to run tasks at regular intervals. E.g. it must send out emails every night to people who subscribe to that service. I have come up with one solution,...
0
by: TDC | last post by:
At system start I get the OnStart. When the system shuts down, do I *just* get an OnShutdown, or will I get both and OnStop and an OnShutdown? If you only get the OnShutdown, I find it odd that...
1
by: Croco Stimpy | last post by:
I have a service that must know when the OS shuts down, so it can perform some cleanup. I just found that the OnShutDown event never fires when the machine shuts down! I did some checking and...
2
by: lb.weissman | last post by:
Hi, I have a simple service, which I want to stop normally. I added the method OnShutdown, and set the CanShutdown property to true. Still, when I restart the computer my OnShutdown method is...
0
by: Klaus Unterberg | last post by:
Hello, does anyone know, how to make an EventLog in service event OnShutdown? It seems that OnShutdown cannot make an entry to the eventlog.writeentry(). Even when Eventlog is listed in the...
14
by: madankarmukta | last post by:
Hi , I want to commit the chages/ want to do some activity on service's OnShutuDown().But i found that It neven get's called ..when i shut down the system or when i power it off..in Both the cases...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
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
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,...
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.