EventLog Class

  • Thread starter Thread starter McKool
  • Start date Start date
M

McKool

Hello.

I'm making a Windows service with C#. This service connect a comm Port when
start and disconnect it when stop. I use an EventLog class to write
information about this service, by example, when the port get connect or
disconnect.

All work ok until the moment when the computer shutdown. If I stop the
service manually before window shutdown, there is not any problem. If the
service still run and windows is shutting down, the computer hang on after
terminate all programs and services (after the window message box "Windows
is being shutting down"). Only what I can see is the Mouse pointer and the
blue screen. If I do not use the EventLog class, the computer shutdown OK.

Every time when i use the Event log make something like:

MyEvents.WriteEntry(System.String.Format("Error: {0}",strError));
MyEvents.Close();

What can i doing wrong?

Thanks in advance....
KW
 
Hi,

You have an event on the windows service that detects when the machine is
shutting down, if this event is triggered dump whatever is necessary and do
not dump it on the OnStop event.

protected override void OnShutdown()
{
base.OnShutdown ();
}
hope this helps
 
Back
Top