虚拟主机上asp.net运行权限不足问题及解决
作者:互联网
2009-06-30
有些时候我们写的asp.net应用程序是运行在虚拟主机上。有一些虚拟主机可能是由于安全的考虑,对asp.net做了权限设置,会导致我们的应用程序无法正常运行。
问题现象:
由于某种原因,asp.net不能加载某些dll文件,出现如下错误提示: Server Error in '/' Application.
---------------------------------------------
Required permissions cannot be acquired.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Security.Policy.PolicyException: Required permissions cannot be acquired.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[PolicyException: Required permissions cannot be acquired.]
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) +2738293
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +57
[FileLoadException: Could not load file or assembly 'Microsoft.Practices.ObjectBuilder, Version=1.0.51205.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +211
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +141
System.Reflection.Assembly.Load(String assemblyString) +25
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +32
问题分析:
根据我的观察,asp.net应用程序直接生成的dll可以正常加载,由asp.net直接调用的外部dll也可以正常加载,但是仅被外部dll引用的其他外部dll不能加载。我的猜想是:由于权限是不完全的,asp.net应用本身生成的dll和直接引用的dll可以通过权限的继承获得权限,而仅被外部dll引用的其他外部dll因为权限的限制不能继承权限,因此出现了权限不足的问题。
问题解决:
通过在我电脑的试验,推测虚拟主机上修改了根web.config(在我电脑上其位置为C:WINDOWSMicrosoft.NETFrameworkv2.0.50727CONFIG)的设置.
默认web.config的权限设置节如下:
推测虚拟主机上修改之后的设置:
例:
最近已经不研究aps.net了,因此也没有认真去查找深层的原因,或许我的认识还有误。希望那位高手可以道出深层的原因,或指正我的错误。
相关标签:
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
详解.NET Core如何构建一个弹性的HTTP请求机制
.NET Core使用Redis实现创建分布式锁
.NET内存管理释放的两种方式
基于.NET8实现WinFrom应用窗口自动缩放功能
浅析如何在 ASP.NET Core中实现速率限制
.NET Core 委托原理解析(最新推荐)
.NET 9 new features-Microsoft.ML.Tokenizers 库(文本标记化功能)
如何在 .NET 中使用 Tesseract 识别图片文字
ASP.NET Core Web API之Token验证的实现
asp.net core web api项目添加自定义中间件的实现
AI精选
Billie Eilish 卡通版 3D 渲染提示词
从程序员到AI工程师:距离有多远?附全套学习路线图
ArkClaw 养虾省钱攻略,这 10% 的返利你还不知道?
大模型就是你雇的员工:从职场管理学看 AI 协作范式的三次进化
MinerU JS/TS SDK 深度指南:JavaScript/TypeScript 开发者的 PDF/文档解析利器
AI 自动值夜班时代来了!Claude Code 刚刚推出 Routines
一天一个开源项目(第74篇):OpenCLI - 把任意网站变成零成本 CLI 工具的 AI Agent 基础设施
就在刚刚,腾讯版 Hermes Agent 来了!快速部署,安装即用!
