matt.griffith - thinking out loud

 Monday, October 07, 2002

Bug in ServiceBase

I think I found a bug in System.ServiceProcess.ServiceBase. If you create a Windows Service using ServiceBase, and you enable AutoLogging, the service will hang on startup if the Application event log is full. You will also get an error when trying to stop the service.

The following steps will reproduce the problem using VS.NET running on .NET RTM with SP2 installed.

  1. Create a new Windows Service project.
  2. Verify that the AutoLog property is set to True.
  3. Add and installer to the project.
  4. Build the project.
  5. Install the service using InstallUtil.exe.
  6. Start the service and verify that it runs normally when the event log is not full.
  7. Stop the service.
  8. Fill the event log. (Calling System.Diagnostics.EventLog.WriteEntry() in an infinite loop does the job nicely.)
  9. Try to start the service.
  10. Observe the lovely error.

These steps assume you haven't changed the default Windows 2000/XP Application Event Log settings.

To get around this problem just set AutoLog to False and write your own event log entries. But be sure to handle the System.ComponentModel.Win32Exception that is thrown when the event log fills up.

10:27:21 PM