I’m making calls in a transaction, and when an exception is thrown (thus preventing my scope.complete()) I don’t see them, even though I know they were called.
[Edit: For clarification – this is running on Server 2008 R2, .Net 3.5]
[Edit: added example – basically answers the question, but if someone could cite documentation somewhere]
EventLog.WriteEntry("Start.");
using(TransactionScope scope = new TransactionScope()) {
EventLog.WriteEntry("Middle.");
throw new applicationexception("Whatever");
scope.Complete();
}
EventLog.WriteEntry("End.");
My event log shows only Start and End.
EventLog does not support transactions. I don’t think there is any specific documentation on this. Which makes sense since the documentation rarely mentions things that are not supported unless there is some explicit reason to do so (clarifications, common misconception, etc.).
From a practical point of view a simple test shows that messages are logged even if the transaction is rolled back:
In the event viewer I see 3 events (“Start”, “123”, “End”).
From a theoretical point of view the
EventLogwould need to have a resource manager to participate in the transaction. EitherEventLogwould need to implementIEnlistmentNotificationor contain a class that implementsIEnlistmentNotification. An inspection ofEventLogin reflector shows that it doesn’t implementIEnlistmentNotification.