user745607
user745607

Reputation: 717

c# windows service in windows 7 The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security

I am runing c# windows service in windows 7.i am getting this error.

{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) at System.Diagnostics.EventLog.SourceExists(String source, String machineName) at System.Diagnostics.EventLog.VerifyAndCreateSource(String sourceName, String currentMachineName) at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID) at eFpdaDMSservice.Utils.GetRegValue(RegistryKey regKey, String strSubKey, String strName, String strDefault)

I have given permissions in the registry

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog

it is breaking at this point

strTempDir = Environment.GetEnvironmentVariable("temp");
            **strLogDir = Utils.GetRegValue(Registry.LocalMachine,REG_KEY,"logdir",strTempDir);**

Any suggestions appreciated

Upvotes: 1

Views: 892

Answers (1)

Raghu
Raghu

Reputation: 2768

What account are you running the service under ? You can try to change the Account to LocalSystem and see if it fixes your problem.

enter image description here

Upvotes: 1

Related Questions