我收到以下异常.我已经在注册表编辑的事件日志中完全控制了 Asp.net 帐户.
I am getting the following exception. I have given full control to Asp.net account on Eventlogs in Registry edit.
[SecurityException: 未找到源,但部分或全部事件无法搜索日志.无法访问的日志:安全性.]
[SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.]
System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate) +664
System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate) +109
System.Diagnostics.EventLog.SourceExists(String source) +14 Microsoft.ApplicationBlocks.ExceptionManagement.DefaultPublisher.VerifyValidSource() +41
我猜这是因为服务器上的一些配置问题?
I guess this is due to some configuration issue on server?
EventLog.SourceExists
通过HKLMSYSTEMCurrentControlSetserviceseventlog
的子键枚举查看如果它包含具有指定名称的子项.如果运行代码的用户帐户在找到目标源之前对其尝试访问的子项(在您的情况下为 Security
子项)没有读取权限,您将看到异常就像你描述的那样.
EventLog.SourceExists
enumerates through the subkeys of HKLMSYSTEMCurrentControlSetserviceseventlog
to see if it contains a subkey with the specified name. If the user account under which the code is running does not have read access to a subkey that it attempts to access (in your case, the Security
subkey) before finding the target source, you will see an exception like the one you have described.
处理此类问题的常用方法是在安装时注册事件日志源(在管理员帐户下),然后假设它们在运行时存在,如果目标事件日志源在运行时实际上不存在,则允许将任何产生的异常视为意外.
The usual approach for handling such issues is to register event log sources at installation time (under an administrator account), then assume that they exist at runtime, allowing any resulting exception to be treated as unexpected if a target event log source does not actually exist at runtime.
这篇关于未找到源,但无法搜索部分或全部事件日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!