asp.net权限设置可能导致应用程序无法正常运行(转)
生活随笔
收集整理的這篇文章主要介紹了
asp.net权限设置可能导致应用程序无法正常运行(转)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
| asp.net權限設置可能導致應用程序無法正常運行?? 有些時候我們寫的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的權限設置節如下: 推測虛擬主機上修改之后的設置: 他首先設置了allowOverride為false,這就阻止了在用戶web.config中重新定義權限的能力。然后,他定義trust level為High,而不是默認的Full。經我測試,只要trust level不為Full,僅被外部dll引用的其他外部dll就不能被加載。因此,我建議技術支持將allowOverride節設置為true。這樣我就可以在web.config中重新指定權限了。 |
轉載于:https://www.cnblogs.com/wj110reg/articles/1020960.html
總結
以上是生活随笔為你收集整理的asp.net权限设置可能导致应用程序无法正常运行(转)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: redis实现数据库(一)
- 下一篇: 灵活运用 SQL Server 数据库的