码迷,mamicode.com
首页 > 其他好文 > 详细

当访问EventLog时,抛出SecurityException

时间:2014-08-11 18:13:23      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:securityexception   run as administrator   

当调用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‘

当访问EventLog时,抛出SecurityException,布布扣,bubuko.com

当访问EventLog时,抛出SecurityException

标签:securityexception   run as administrator   

原文地址:http://13713878410.blog.51cto.com/9096807/1538623

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!