使用MS的Ent Lib(企业库)开发时,提示“System.Security.SecurityException: 不允许所请求的注册表访问权”--转载自蝈蝈俊
2005-11-16 09:44
281 查看
我们在WEB站点使用企业库的时候,有时候会有如下的异常产生:
安全性异常
说明: 应用程序试图执行安全策略不允许的操作。要授予此应用程序所需的权限,请与系统管理员联系,或在配置文件中更改该应用程序的信任级别。
异常详细信息: System.Security.SecurityException: 不允许所请求的注册表访问权。
堆栈跟踪:
[SecurityException: 不允许所请求的注册表访问权。]
Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +473
System.Diagnostics.EventLog.CreateEventSource(String source, String logName, String machineName, Boolean useMutex) +443
System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) +347
System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category) +21
......
Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterInstances..ctor(String categoryName, String counterName, Boolean createNewInstance)
Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent.AddPerformanceCounter(String category, String[] counterNames, Boolean createNewInstance) Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent.Initialize(String counterCategory, String[] counterNames, Boolean createNewInstance, String eventLogSource, EventLogIdentifier[] eventIds)
造成这个的原因是企业库的公共项目中:Instrumentation 目录下有操作日志、性能的代码。而这些代码需要一定的权限才可以执行。
解决方案:
1、去掉这些代码。(这会是一个痛苦的经历,代码割舍不清呀)
2、给IUSR 帐户访问注册表的权限(安全问题呀!)
我们当然不推荐这2个做法:
我们推荐的做法:重新编译 Microsoft.Practices.EnterpriseLibrary.Common 项目,编译时把其中 Conditional Compilation Constants 设置中除 DEBUG;TRACE 外的其他项都去掉。
具体步骤请参看:
http://dotnetjunkies.com/WebLog/sskokku/archive/2005/03/25/61376.aspx
安全性异常
说明: 应用程序试图执行安全策略不允许的操作。要授予此应用程序所需的权限,请与系统管理员联系,或在配置文件中更改该应用程序的信任级别。
异常详细信息: System.Security.SecurityException: 不允许所请求的注册表访问权。
堆栈跟踪:
[SecurityException: 不允许所请求的注册表访问权。]
Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +473
System.Diagnostics.EventLog.CreateEventSource(String source, String logName, String machineName, Boolean useMutex) +443
System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) +347
System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category) +21
......
Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterInstances..ctor(String categoryName, String counterName, Boolean createNewInstance)
Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent.AddPerformanceCounter(String category, String[] counterNames, Boolean createNewInstance) Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent.Initialize(String counterCategory, String[] counterNames, Boolean createNewInstance, String eventLogSource, EventLogIdentifier[] eventIds)
造成这个的原因是企业库的公共项目中:Instrumentation 目录下有操作日志、性能的代码。而这些代码需要一定的权限才可以执行。
解决方案:
1、去掉这些代码。(这会是一个痛苦的经历,代码割舍不清呀)
2、给IUSR 帐户访问注册表的权限(安全问题呀!)
我们当然不推荐这2个做法:
我们推荐的做法:重新编译 Microsoft.Practices.EnterpriseLibrary.Common 项目,编译时把其中 Conditional Compilation Constants 设置中除 DEBUG;TRACE 外的其他项都去掉。
具体步骤请参看:
http://dotnetjunkies.com/WebLog/sskokku/archive/2005/03/25/61376.aspx
相关文章推荐
- System.Security.SecurityException: 不允许所请求的注册表访问权 一个简单的解决办法
- 异常详细信息: System.Security.SecurityException: 不允许所请求的注册表访问权
- 解决Sql2008弹出 System.Security.SecurityException: 不允许所请求的注册表访问权。
- System.Security.SecurityException: 不允许所请求的注册表访问权。
- 安全异常 -------异常详细信息: System.Security.SecurityException: 不允许所请求的注册表访问权。
- 解决System.Security.SecurityException: 不允许所请求的注册表访问权
- 企业库使用异常不允许所请求的注册表访问权 解决办法
- System.Security.SecurityException: 不允许所请求的注册表访问权
- 开发微信发红包时,本地测试没有问题发布IIS上提示 System.Security.Cryptography.CryptographicException: 系统找不到指定的文件。
- Windows XP下使用ASP.Net 访问Access数据库提示“System.Data.OleDb.OleDbException: 未指定的错误”的解决办法
- VS2008 无法创建新项目,提示“不允许所请求的注册表访问权”
- ASP.NET中异常详细信息: System.Security.SecurityException: 不允许所请求的注册表访问权
- 异常详细信息: System.Security.SecurityException: 不允许所请求的注册表访问权
- [C#] 解决Silverlight反射安全关键(SecuritySafeCritical)时报“System.MethodAccessException: 安全透明方法 XXX 无法使用反射访问”的问题
- 使用Enterprise Library时出现“不允许所请求的注册表访问权”错误
- 异常详细信息: System.Security.SecurityException: 请求失败。
- 使用wmi引起的 System.UnauthorizedAccessException:拒绝访问
- iOS 10 不提示「是否允许应用访问数据」,导致应用无法使用的解决方案
- [EntLibFAQ]“不允许所请求的注册表访问权”的解释[0508Update]
- Requested registry access is not allowed(不允许所请求的注册表访问权)