我正在一個事務中調用,當拋出一個異常(從而阻止我的scope.complete())時,我沒有看到它們,儘管我知道它們被調用。調用WriteEntry方法時,System.Diagnostics.EventLog類是否參與事務?
[編輯:爲了澄清 - 這是Server 2008上運行R2,淨3.5]
[編輯:添加例子 - 基本上回答了這個問題,但如果有人能列舉文檔某處]
EventLog.WriteEntry("Start.");
using(TransactionScope scope = new TransactionScope()) {
EventLog.WriteEntry("Middle.");
throw new applicationexception("Whatever");
scope.Complete();
}
EventLog.WriteEntry("End.");
我的事件日誌只顯示開始和結束。