"Cannot find description for event ID X in source Y."

I am trying to write custom events from my web application to the Windows event log. I’m unlucky that the message lines are working, I keep getting "Description for event ID X in source Y could not be found."

In an attempt to narrow it down, I decided to write the event to a source that already exists on my machine. I just looked at one of the events that were already written out, in particular the SceCli 1704 event.

I am executing 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 the event viewer:

Cannot find description for event ID (1704) in source (SceCli). The local registry may not display the necessary registry data or message DLL files to display messages from a remote computer. You can use the / AUXSOURCE = flag to get this description; see Help and Support. The following information is part of an event: The event log file is corrupt.

I'm not sure what I am missing here. I am writing the same event that already exists, and it still cannot find the message line.

+4
source share
2 answers

I also had a similar problem. After I did a lot of research, I performed the following steps in accordance with this article http://www.codeproject.com/Articles/4166/Using-MC-exe-message-resources-and-the-NT-event- lo Everything seemed to be in place. Except for one thing .. I realized this when I came across this msdn http://msdn.microsoft.com/en-us/library/windows/desktop/aa363661(v=vs.85).aspx

As stated in the last paragraph. "If an application calls RegisterEventSource and passes a source name that cannot be found in the registry, the event logging service uses the application log by default. However, since there are no message files, the event viewer cannot match any event IDs or event categories to the description line and displays an error For this reason, you must add a unique event source to the registry for your application and specify the message file. 'Thus, my application name in RegisterEventSource did not match the name Appendicies in the registry. I fixed it and now it works ... So please double-check your entries in the registry, if you are faced with this problem.

+1
source

Can you see other events correctly? Most likely, you cannot use this specific source and event identifier (SceCli / 1704) because the C # event class does not provide the correct number of parameters to match the event pattern in the event message file. I think that it will only work with sources that have only "% 1" in the event message file (for more details see http://www.eventid.net/show-DocId-22.htm ).

In any case, I think you need to create a source for your own application (if it does not exist), and then write a log entry. Before recording an event, check if the source exists and create it if it is not:

 if (!EventLog.SourceExists("MyWebApp")) EventLog.CreateEventSource("MyWebApp", "Application"); EventLog.WriteEntry("MyWebApp", "Some message", EventLogEntryType.Information, 1704); 
0
source

Source: https://habr.com/ru/post/1486016/


All Articles