OnShutdown not executing in Windows service

P

Peter Meinl

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.
 
S

Stephen Martin

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top