KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
My following code fails with "...has already been registered as a source on the local computer" even though I'm doing checks first: lock ( eventLock ) { string eventLog = Constants.EventLogPL; string eventSrc = Constants.EventSrcPL; if (!EventLog.Exists(eventLog)) { if (!EventLog.SourceExists(eventSrc)) { try { EventLog.CreateEventSource(eventSrc, eventLog); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } } } } I'd have thought my call to !EventLog.SourceExists would have been enough to prevent my error! I'm on 2010 .NET 4 and Windows 7 64 compiling to any CPU. Edit: Updated code to get Constant's to locals to check they don't change, and use locking to make sure only one thread can test and create. Code still fails with the same error.
Tags (comma-separated)
Save Edits
Cancel