Description for event id from source cannot be found

后端 未结 11 603
[愿得一人]
[愿得一人] 2020-11-29 01:55

When I write a log into windows event log, I get the event below, what\'s the root cause of this message, and how can I fix it? Many Thanks

The descri

11条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 02:24

    How about a real world solution.

    If all you need is a "quick and dirty" way to write something to the event log without registering "custom sources" (requires admin rights), or providing "message files" (requires work and headache) just do this:

    EventLog.WriteEntry(
        ".NET Runtime", //magic
        "Your error message goes here!!",
        EventLogEntryType.Warning,
        1000); //magic
    

    This way you'll be writing to an existing "Application" log without the annoying "The description for Event ID 0 cannot be found"

    If you want the "magic" part explained I blogged about it here

提交回复
热议问题