I recently lost a good amount of hair on trying to resolve an issue while trying to execute an application. This application was running successfully on one server and I was trying to configure it to run on this new server too. While doing so, the application refused to run and did prompt me this follow exceptions. After tons and tons of digging (includes pulling out my hair too), I found that solution was a simple one line command.
Unhandled Exception: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security. at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate) at System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate) at System.Diagnostics.EventLog.SourceExists(String source)
The FIX:
Run the following line of code (replace MyEventSourceName to your application name) in an elevated PowerShell command prompt.
[System.Diagnostics.EventLog]::CreateEventSource(“MyEventSourceName”, “Application”)

