windows 7中的c#windows服务未找到源,但无法搜索部分或所有事件日志。不可访问日志:安全性

windows 7中的c#windows服务未找到源,但无法搜索部分或所有事件日志。不可访问日志:安全性,c#,C#,我正在windows 7中运行c#windows服务。我收到此错误 {System.Security.SecurityException:找不到源,但找到了一些 或无法搜索所有事件日志。无法访问的日志:安全性。 在System.Diagnostics.EventLog.FindSourceRegistration(字符串源、, 字符串machineName,布尔只读)位于 System.Diagnostics.EventLog.SourceExists(字符串源,字符串 机器名称)在 Syste

我正在windows 7中运行c#windows服务。我收到此错误

{System.Security.SecurityException:找不到源,但找到了一些 或无法搜索所有事件日志。无法访问的日志:安全性。 在System.Diagnostics.EventLog.FindSourceRegistration(字符串源、, 字符串machineName,布尔只读)位于 System.Diagnostics.EventLog.SourceExists(字符串源,字符串 机器名称)在 System.Diagnostics.EventLog.VerifyAndCreateSource(字符串sourceName, 字符串currentMachineName)位于 System.Diagnostics.EventLog.WriteEntry(字符串消息, EventLogEntryType类型,Int32 eventID,Int16类别,字节[]rawData) 在System.Diagnostics.EventLog.WriteEntry(字符串源,字符串 消息,EventLogEntryType类型,Int32 eventID,Int16类别,字节[] 在System.Diagnostics.EventLog.WriteEntry(字符串源、, 字符串消息,EventLogEntryType,Int32 eventID)位于 eFpdaDMSservice.Utils.GetRegValue(RegistryKey-regKey,字符串 strSubKey、字符串strName、字符串strDefault)

我已在注册表中授予权限

HKEY\U LOCAL\U MACHINE\System\CurrentControlSet\Services\EventLog

它在这一点上被打破了

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

您使用什么帐户运行服务?您可以尝试将帐户更改为LocalSystem,看看它是否解决了您的问题


您使用哪个帐户运行服务?您可以尝试将帐户更改为LocalSystem,看看它是否解决了您的问题