473,320 Members | 2,000 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 6034

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: David Conorozzo | last post by:
I am able to create new sources using CreateEventSource. I can call GetEventLogs, I can delete sources, I can see if sources exist BUT, as soon as I try a "WriteEntry", I get an exception: ...
5
by: Philip Wagenaar | last post by:
I have a Windows Form application that monitors a directory using the System.IO.FileSystemWatcher. On the event created I run a sub that sends an xml file over http to a service. When I copy...
3
by: musosdev | last post by:
Hi I'm using the following code in a global class to add to the Windows EventLog every time a try{} catch{} block fails... if(!EventLog.SourceExists("darts"))...
5
by: Ankit Aneja | last post by:
This is my problem. I am using Visual 2003, .Net framework 1.1 and the Application Block I configured the DAAB using the Enterprise Library Configuration now this is the error which is coming ...
1
by: martin | last post by:
Hi, I'm having some problems with the System.Diagnostics.EventLog class in .NET 2.0 I need to recreate an event message source inside a new log but the messages keeps ending up in the old...
0
by: Klaus Unterberg | last post by:
Hello, does anyone know, how to make an EventLog in service event OnShutdown? It seems that OnShutdown cannot make an entry to the eventlog.writeentry(). Even when Eventlog is listed in the...
1
by: Jeff | last post by:
hi ..Net 2.0 I've created the code below and think I've executed it. After I thought I've executed it I checked in EventLog on the computer (win2k3) and no entry was added. This could mean 2...
1
by: Jacob | last post by:
I have the following code in a class... --------------------------------------------------------------------------------- .... Private _eL As EventLog = Nothing Private _eLName As String =...
6
by: Steve | last post by:
Hi All I have a windows forms Application (SAM) in vb.net 2008 using .net framework V2 One and only one customer out of 30 customers is getting errors daily where they have to close and...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.