G
Guest
Hi having problems writing to the event log, I have the code below,
using System.Diagnostics;
System.Diagnostics.EventLog myEventLog = new System.Diagnostics.EventLog();
myEventLog.Log="newlog";
myEventLog.Source="newlog";
myEventLog.WriteEntry("another entry");
//this works but when I try
myEventLog.WriteEntry("Consoleapp1","testmessage",EventLogEntryType.Warning)
I get a compiler error-Static member 'member' cannot be accessed with an
instance reference; qualify it with a type name instead
so I tried
System.Diagnostics.EventLog.WriteEntry("Consoleapp1","testmessage",EventLogEntryType.Warning );
this builds ok but does not seem to write to the event.
thanks.
using System.Diagnostics;
System.Diagnostics.EventLog myEventLog = new System.Diagnostics.EventLog();
myEventLog.Log="newlog";
myEventLog.Source="newlog";
myEventLog.WriteEntry("another entry");
//this works but when I try
myEventLog.WriteEntry("Consoleapp1","testmessage",EventLogEntryType.Warning)
I get a compiler error-Static member 'member' cannot be accessed with an
instance reference; qualify it with a type name instead
so I tried
System.Diagnostics.EventLog.WriteEntry("Consoleapp1","testmessage",EventLogEntryType.Warning );
this builds ok but does not seem to write to the event.
thanks.