Win7上的ASP.Net中的EventLog权限失败 [英] EventLog permission failing in ASP.Net on Win7

查看:160
本文介绍了Win7上的ASP.Net中的EventLog权限失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Win7中运行的ASP.Net应用程序.net 3.5 SP1。在登录过程中,ASP.Net登录控件中的某些内容导致事件日志中写入了安全日志(这对我来说是可以接受的)。问题在于,该应用似乎无权执行此操作。出现错误:

I have an ASP.Net app .net 3.5 SP1, running in Win7 . During the login process, something within the ASP.Net login control is causing a write to the security log (this sounds acceptable to me) in the event log. The problem is that it seems the app doesn't have permission to do this. There error is:

说明:应用程序尝试执行安全策略不允许的操作。要授予此应用程序所需的权限,请与系统管理员联系或在配置文件中更改应用程序的信任级别。

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.

异常详细信息:System.Security.SecurityException:请求类型为'System.Diagnostics.EventLogPermission,System,Version = 2.0的权限。 0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'失败。

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Diagnostics.EventLogPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

堆栈跟踪未显示应用程序中的任何一行代码,而所有代码都显示在框架中。
最后5行是:
System.Security.CodeAccessSecurityEngine.Check(对象需求,StackCrawlMark& stackMark,布尔值isPermSet)+0
System.Security.CodeAccessPermission.Demand()+61
System.Diagnostics.EventLog..ctor(字符串logName,字符串machineName,字符串源)+125
System.Diagnostics.EventLog..ctor()+24
System.Diagnostics.EventLog.WriteEntry (字符串源,字符串消息,EventLogEntryType类型,Int32 eventID,Int16类别,Byte [] rawData)+52

The stack trace doesn't show a single line of code from my application, its all in the framework. The last 5 lines are: System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0 System.Security.CodeAccessPermission.Demand() +61 System.Diagnostics.EventLog..ctor(String logName, String machineName, String source) +125 System.Diagnostics.EventLog..ctor() +24 System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) +52

该相同的应用程序在XP SP2上可以正常工作。我已经四处搜寻,找不到授予权限的方法。我尝试过以本地系统和ApplicationPoolIdentity的身份运行应用程序池。

This same app works fine on XP SP2. I've hunted around and can't find how to give permissions. I've tried running hte app pool as LocalSystem and ApplicationPoolIdentity.

最简单的方法是什么?它是我的本地开发机器,我不在乎是否会打开安全漏洞,只要我不必修改代码即可(即,我需要将解决方案更改为INETMGR或web.config或某些本地权限,等等) )。

Whats the easiest way to get this running? Its my local dev machine and I don't care if I open up security holes, as long as I don't have to modify code (ie I need the solution to be an INETMGR change or web.config or some local permissions, etc).

谢谢!

推荐答案

链接似乎是在讨论您遇到的问题。
我不确定XP上的默认CAS(代码访问安全性)与win 7之间的区别,但是写入事件日志的程序集(以及所有调用程序集)必须具有EventLogPermission。

This link appears to discuss the issue you are having. I am not sure about the differences between the default CAS (code access security) on XP vs. win 7, however the assembly writing to the event log (and all calling assemblies) must have EventLogPermission.

您可以添加 AllowPartiallyTrustedCallers 属性或对程序集进行签名与强名称密钥

You can add the AllowPartiallyTrustedCallers attribute or sign the assembly with a strong name key.

这篇关于Win7上的ASP.Net中的EventLog权限失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆