电信主站 网通分站
购买流程 付款方式 常见问题 在线提问 续租服务 购物车
用户名: 密 码: 忘记密码?
首 页
域名注册
虚拟主机
双线主机
服务器租用
VPS主机
企业邮局
代理专区
客服中心
虚拟主机行业资讯 虚拟主机评测对比 互联网最新动态 技术学院 站长资讯 在线教程 网站运营
搜索优化 服务器 网络编程 图形图象 站长之家 网页制作 操作系统
冲浪宝典 软件教学 视频通信 办公软件 邮件系统 网络安全 认证考试
您当前位置:西部数码->资讯中心-> 网站运营-> 网站运营
虚拟主机上asp.net运行权限不足问题及解决-.NET教程,Asp.Net开发
作者:网友供稿 点击:53
  西部数码-全国虚拟主机10强!20余项虚拟主机管理功能,全国领先!第6代双线路虚拟主机,南北访问畅通无阻!虚拟主机可在线rar解压,自动数据恢复设置虚拟目录等.虚拟主机免费赠送访问统计,企业邮局.Cn域名注册10元/年,自助建站480元起,免费试用7天,满意再付款!P4主机租用799元/月.月付免压金!
文章页数:[1] 
 

   有些时候我们写的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:\windows\microsoft.net\framework\v2.0.50727\config)的设置.
    默认web.config的权限设置节如下:
<location allowoverride="true">
        <system.web>
            <securitypolicy>
                <trustlevel name="full" policyfile="internal" />
                <trustlevel name="high" policyfile="web_hightrust.config" />
                <trustlevel name="medium" policyfile="web_mediumtrust.config" />
                <trustlevel name="low"  policyfile="web_lowtrust.config" />
                <trustlevel name="minimal" policyfile="web_minimaltrust.config" />
            </securitypolicy>
            <trust level="full" originurl="" />
        </system.web>
</location>
    推测虚拟主机上修改之后的设置: <location allowoverride="false">
        <system.web>
            <securitypolicy>
                <trustlevel name="full" policyfile="internal" />
                <trustlevel name="high" policyfile="web_hightrust.config" />
                <trustlevel name="medium" policyfile="web_mediumtrust.config" />
                <trustlevel name="low"  policyfile="web_lowtrust.config" />
                <trustlevel name="minimal" policyfile="web_minimaltrust.config" />
            </securitypolicy>
            <trust level="high" originurl="" />
        </system.web>
</location>    他首先设置了allowoverride为false,这就阻止了在用户web.config中重新定义权限的能力。然后,他定义trust level为high,而不是默认的full。经我测试,只要trust level不为full,仅被外部dll引用的其他外部dll就不能被加载。 因此,我建议技术支持将allowoverride节设置为true。这样我就可以在web.config中重新指定权限了。
例:<trust level="full" originurl="" />

    最近已经不研究aps.net了,因此也没有认真去查找深层的原因,或许我的认识还有误。希望那位高手可以道出深层的原因,或指正我的错误。

转自:动态网站制作指南 | www.knowsky.com

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
相关主题
文章页数:[1] 
Google
热门文章
·ASP.NET的安装与运行环境-.NET教程,Asp.Net开发
·运用.NET+SQL Server2005构建多层网站(3)-.NET教程,数据库应用
·JAVA写的四则混合运算-JSP教程,Java技巧及代码
·获取高精度的时间差,可以用来分析页面运行时间的长短-.NET教程,Asp.Net开发
·基于.Net平台应用程序唯一运行实例C#代码实现-.NET教程,C#语言
·运用.NET+SQL Server2005构建多层网站(1)-.NET教程,数据库应用
·Alexa 世界网站排名研究(下)-网站运营,搜索引擎推广
·优化系统让Photoshop运行更流畅-网页设计,Photoshop
·ASP.NET 2.0运行时简要分析-.NET教程,Asp.Net开发
·手工打造运算符重载过程-.NET教程,C#语言

最新文章
·阿里巴巴明日接受认购 招股价上限或上调
·web2.0时代谁做优秀内容的提供商
·Ranking - 影响排名的六大因素
·站点推广到底是个什么东西
·建站新思路:虚拟整人减压未来网络黄金项目
·07胡润IT富豪榜发布:李彦宏成IT首富
·细说 AdSense 政策:什么是鼓励点击
·中搜 “说再见别说永远”
·商业模式越简单越成功吗?
·国外博客靠广告赚钱营利走向职业化


 
 


版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!

特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。
  打印  刷新  关闭
返回首页 |关于我们 | 联系我们 | 付款方式 | 创业联盟 | 虚拟主机 | 资讯中心 | 友情链接 | 网站地图

版权所有 西部数码(www.west263.com)
CopyRight (c) 2002~2006 west263.com all right reserved.
公司地址:四川成都市万和路90号天象大厦4楼 邮编:610031
电话总机:028-86262244 86263048 86263408 86263960 86264018 86267838
售前咨询:总机转201 202 203 204 206 208
售后服务:总机转211 212 213 214
财务咨询:总机转224 223 传真:028-86264041 财务QQ:点击发送消息给对方635483282
售前咨询QQ:点击发送消息给对方2182518 点击发送消息给对方241975952 点击发送消息给对方275026793 点击发送消息给对方408235859
售后服务QQ:点击发送消息给对方17708515 点击发送消息给对方307742704 点击发送消息给对方287976517 点击发送消息给对方363783715
《中华人民共和国增值电信业务经营许可证》编号:川B2-20030065号