Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Eventlog.DeleteEventSource SecurityException

$
0
0

We have some logging code (.NET 4.5) that needs to log to the event log for debugging/auditing purposes.  The following code blows up with a SecurityException on Windows Server 2012.

 private void RegisterSource(string source, string logName)
        {
            if (EventLog.SourceExists(source))
            {
                EventLog.DeleteEventSource(source);  //We die here
            }

            EventLog.CreateEventSource(source, logName);
        }

SecurityException:

{"Requested registry access is not allowed."}

Note, I am a local admin on this box so not sure why this code is failing.  Please advise.


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>