By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,636 Members | 1,814 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,636 IT Pros & Developers. It's quick & easy.

System.Diagnostics.EventLog.WriteEntry The parameter is incorrect

P: n/a
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.c s: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!

Apr 23 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.