我正在尝试将Server应用程序从Server 2003(和IIS6)移植到Server 2008(IIS7)。写入事件日志时发生System.Security.SecurityException
当我尝试并参观浏览器上的网页我得到这个:
Server Error in ‘/’ Application.
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application’s trust level in the configuration file.
Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and the location of the exception can be identified using the exception stack trace below.
Stack Trace:
[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) +562 System.Diagnostics.EventLog.SourceExists(String source, String machineName) +251
[snip]
这是我做过尝试,并解决它的东西:
给“所有人”完全访问权限的密钥
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Security
。这工作。但自然,我无法在生产中做到这一点。所以我在运行应用程序几分钟后删除了“Everyone”权限,并且错误再次出现。我在安装时使用提升的权限在应用程序日志和安全日志中创建了源(并且我通过regedit验证了它),但错误依然存在。
我给了应用程序在
web.config
文件(和使用appcmd.exe
)完全信任级别,但无济于事。
有没有人有一个洞察力,可以在这里做什么?
PS:这是question的后续行动。我遵循了给定的答案,但无济于事(参见上面的#2)。
我在尝试写入作为NetworkService运行的.Net服务中的自定义源时遇到此问题。我只是将事件日志源更改为与通过.Net服务安装程序包安装的服务名称匹配,并且它在没有设置注册表权限的情况下工作。我注意到它通过查看服务名称已经在HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ EventLog \ Application – 2011-03-31 18:10:36
中的一个键相关的:http://stackoverflow.com/questions/286060/what-do-i-need-to-change -to-alllow-my-iis7-asp-net-3-5-application-to-create-an/7848414#7848414 – 2015-04-05 18:06:48
另一个可能的答案:右键单击exe并选择“以管理员身份运行” – MacGyver 2016-01-21 08:15:23