I'm trying to write custom events from my web application to the windows event log. I've had no luck getting the message strings to work, I keep getting "The description for Event ID X in Source Y cannot be found."
In trying to narrow this down I decided to write out an event to a source that already exists on my machine. I just looked at one of the events that was already written out, specifically SceCli event 1704.
I execute the following code:
var log = new EventLog("Application");
log.Source = "SceCli";
var ev = new EventInstance(1704, 0, EventLogEntryType.Information);
log.WriteEvent(ev);
However, this still gives me the following in Event Viewer:
The description for Event ID ( 1704 ) in Source ( SceCli ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: The event log file is corrupt..
I'm not sure what I'm missing here. I'm writing out the exact same event that already exists, and it still can't find the message string.