0
在Windows 2008服務器中,當我清除EventLog時,我停止獲取後續的EntryWritten事件。代碼看起來很簡單:事件日誌在清除後停止發送EntryWritten事件
private void eventLog1_EntryWritten(object sender, System.Diagnostics.EntryWrittenEventArgs e)
{
label1.Text = "Got entry at " + DateTime.Now;
}
private void write_Click(object sender, EventArgs e)
{
eventLog1.WriteEntry("Hello");
}
private void clear_Click(object sender, EventArgs e)
{
eventLog1.Clear();
}
this.eventLog1.EnableRaisingEvents = true;
this.eventLog1.Log = "MY_LOG";
this.eventLog1.Source = "Test";
this.eventLog1.SynchronizingObject = this;
this.eventLog1.EntryWritten += new System.Diagnostics.EntryWrittenEventHandler(this.eventLog1_EntryWritten);
在Windows 2003服務器中,代碼正常工作。 有沒有人有一個想法,爲什麼發生這種情況,或如何使它工作?