温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

当访问EventLog时,抛出SecurityException

发布时间:2020-07-07 23:21:07 来源:网络 阅读:2302 作者:13713878410 栏目:编程语言

当调用EventLog.SourceExists("source1")时,抛出一下异常


System.Security.SecurityException was unhandled
  HResult=-2146233078
  Message=The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.
  Source=System
  StackTrace:
       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)
       at EventLogApp.Program.Main(String[] args) in E:\MyWorkspace\Projects\Tuturial\CSharpStudy\EventLogApp\Program.cs:line 14
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:


解决方案:

右键点击要运行的文件,执行“run as administrator‘


Creating event log sources without administrative rights

http://www.neovolve.com/post/2008/11/12/Creating-event-log-sources-without-administrative-rights.aspx

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI