System.Diagnostics.EventLog.WriteEntry The parameter is incorrect

J

jammendolia

Hello all,

I am having an intermittent exception occur when writing the the
eventlog from a windows service application written in c#, running on
a Win2k SP4 server.


Here's the code:

void writeToEventLog(string msg, bool error) {

System.Diagnostics.EventLogEntryType msgType = error ?
System.Diagnostics.EventLogEntryType.Error :
System.Diagnostics.EventLogEntryType.Information;

this.EventLog.WriteEntry(msg, msgType);
}


99% of the time, this seems to work just fine but every so often, it
throws the following exception:

System.ComponentModel.Win32Exception: The parameter is incorrect
at System.Diagnostics.EventLog.WriteEvent(Int32 eventID, Int16
category, EventLogEntryType type, String[] strings, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID, Int16 category)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type)
at FileService.filetestProc.writeToEventLog(String Msg, Boolean
error) in c:\dev\projects\services\FileService\FileService.cs:line 166


The method calling this is running in a seperate thread from the main
service thread, and the exception seems to occur when the thread is
getting ready to exit.

Does anyone know what could be causing it?

Thanks in advance!
 

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