Problem and solution of ASP.net running on virtual host

Source: Internet
Author: User
Tags reflection stack trace

Sometimes we write asp.net applications that run on a virtual host. Some virtual hosts may be due to security considerations, the ASP.net permissions to set, can cause our application will not function properly.

Problem phenomenon:

For some reason, asp.net cannot load some DLL files, and the following error prompts: Server error in '/' Application.

---------------------------------------------

Required permissions cannot be acquired.





Description:an Unhandled exception occurred the during of the current Web request. Please review the "stack Trace for" 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 is 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, Cultur E=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

Problem Analysis:

According to my observation, the DLL directly generated by the ASP.net application can load normally, and external DLLs called directly by ASP.net can also load normally, but other external DLLs referenced only by external DLLs cannot be loaded. My guess is that because permissions are incomplete, the ASP.net application itself generates DLLs and directly referenced DLLs that gain permissions through inheritance of permissions, while other external DLLs referenced only by external DLLs cannot inherit permissions because of permission limitations, resulting in insufficient permissions.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.