2

Is it possible to create an Event ID linked to an error from C# debugging system?

I'm currently writing my code -which still has a small error, click here- for making up really detailed error logs in the event viewer

Community
  • 1
  • 1
Dashzapp
  • 123
  • 4
  • 13

1 Answers1

1

If you want to create an event source you must create it if don't exist :

string cs = "CustomSource";
EventLog elog = new EventLog();

if (!EventLog.SourceExists(cs))
    EventLog.CreateEventSource(cs, cs);

int eventID = 8;
elog.Source = cs;
elog.EnableRaisingEvents = true;
elog.WriteEntry(message, System.Diagnostics.EventLogEntryType.Error,
                    eventID);
aleroot
  • 71,077
  • 30
  • 176
  • 213
  • But this has nothing to do with my problem? – Dashzapp Mar 07 '12 at 13:52
  • What is your problem ? From your question i can't figure out what your problem really is . – aleroot Mar 07 '12 at 13:57
  • That is the problem in my other question. If you see event viewer, you get a series of event ID's next to a certain event (warning, information, ect.). If you do a regular writing to the event viewer, it gets Event ID 0, but I want certain events to be linked at certain IDs, or to create new IDs linked to C# events – Dashzapp Mar 08 '12 at 06:50