當調用EventLog.SourceExists("source1")時,拋出一下異常
成都創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網綜合服務,包含不限于成都網站設計、網站建設、棗陽網絡推廣、微信小程序開發(fā)、棗陽網絡營銷、棗陽企業(yè)策劃、棗陽品牌公關、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們最大的嘉獎;成都創(chuàng)新互聯(lián)為所有大學生創(chuàng)業(yè)者提供棗陽建站搭建服務,24小時服務熱線:028-86922220,官方網址:www.cdcxhl.com
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:
解決方案:
右鍵點擊要運行的文件,執(zhí)行“run as administrator‘
http://www.neovolve.com/post/2008/11/12/Creating-event-log-sources-without-administrative-rights.aspx