G
Guest
Hi
I have the code as below
if(!EventLog.SourceExists("XXXBspMode1")
EventLog.CreateEventSource("XXXBspMode1", "XXXMode1")
myLog = new EventLog()
myLog.Log = "XXXMode1"
myLog.Source = "XXXBspMode1"
myLog.WriteEntry("XXXBspMode1 started", EventLogEntryType.Information, 1, 0)
It looks simple rite? But when I try to run it, I will get the following error, but if I change the name of the source and the log, the error will not appear anymore, what is the problem, how can I solve the problem if I insist to use the XXX as the names? Thanks
Error: System.ArgumentException: The source 'MasBspMode1' is not registered in
og 'XXXMode1'. (It is registered in log 'Application'.) " The Source and Log pr
perties must be matched, or you may set Log to the empty string, and it will au
omatically be matched to the Source property
at System.Diagnostics.EventLog.WriteEvent(Int32 eventID, Int16 category, Eve
tLogEntryType type, String[] strings, Byte[] rawData
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
ype, Int32 eventID, Int16 category, Byte[] rawData
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
ype, Int32 eventID, Int16 category
at ConsoleApplication1.Class1.Main(String[] args) in d:\hkcciii\codes\build223\consoleapplication1\class1.cs:line 372
I have the code as below
if(!EventLog.SourceExists("XXXBspMode1")
EventLog.CreateEventSource("XXXBspMode1", "XXXMode1")
myLog = new EventLog()
myLog.Log = "XXXMode1"
myLog.Source = "XXXBspMode1"
myLog.WriteEntry("XXXBspMode1 started", EventLogEntryType.Information, 1, 0)
It looks simple rite? But when I try to run it, I will get the following error, but if I change the name of the source and the log, the error will not appear anymore, what is the problem, how can I solve the problem if I insist to use the XXX as the names? Thanks
Error: System.ArgumentException: The source 'MasBspMode1' is not registered in
og 'XXXMode1'. (It is registered in log 'Application'.) " The Source and Log pr
perties must be matched, or you may set Log to the empty string, and it will au
omatically be matched to the Source property
at System.Diagnostics.EventLog.WriteEvent(Int32 eventID, Int16 category, Eve
tLogEntryType type, String[] strings, Byte[] rawData
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
ype, Int32 eventID, Int16 category, Byte[] rawData
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
ype, Int32 eventID, Int16 category
at ConsoleApplication1.Class1.Main(String[] args) in d:\hkcciii\codes\build223\consoleapplication1\class1.cs:line 372