470,638 Members | 1,577 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,638 developers. It's quick & easy.

System.Diagnostics.EventLog.WriteEntry The parameter is incorrect

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
0 5678

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by David Conorozzo | last post: by
3 posts views Thread by musosdev | last post: by
1 post views Thread by martin | last post: by
reply views Thread by Klaus Unterberg | last post: by
6 posts views Thread by Steve | last post: by
???
1 post views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.