System.Security.Policy.PolicyException: Required permissions cannot be acquired.

Hello all, ive just uploaded my asp.net site to my hosting, however, im getting the following error, that i was not receiving while the site was runniong of my localhost. Any ideas?

error:
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) +2738645
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 ‘vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ 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

Hosted site is running in medium (or low) trust mode, your test site was running in full trust. Change your local setup to appropriate trust level and debug to see what is going on.

thanks for that, ive added into my web.config file the following lines


<location allowOverride="false">
  <system.web>
    <trust level="Low" originUrl="" />
  </system.web>
</location>

However, im still getting a configuration error message:
Parser Error Message: This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using <location allowOverride=“false”> from an inherited configuration file.
Any ideas?

Please find blow the whole of my web.config file:


<?xml version="1.0"?>

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
	<appSettings/>
  <connectionStrings>
    <add name="Database" connectionString="server=.\\SQLExpress;AttachDbFileName=|DataDirectory|\\Database.mdf;Integrated Security=true;User Instance=true" providerName="System.Data.SqlClient" />
    <add name="EncryptionKeys" connectionString="server=.\\SQLExpress;AttachDbFileName=|DataDirectory|\\Database.mdf;Integrated Security=true;User Instance=true" providerName="System.Data.SqlClient" />
  </connectionStrings>

<location allowOverride="false">
  <system.web>
    <trust level="Low" originUrl="" />
  </system.web>
</location>

  <system.web>
    <compilation debug="true">
	    <assemblies>
        <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      </assemblies>
    </compilation>

    <!---<customErrors mode="RemoteOnly" defaultRedirect="~/errorpage.aspx"/>-->
    <customErrors mode="Off" />

   <authentication mode="Windows"/>

</system.web>

</configuration>


you can use allowOverride=“false” only if the machine settings allows you to.
On your test PC you can do it because you are the admin. On your shared host however you can’t, because the trust level is set by the hosting admins.
To run locally in medium trust mode [recommended] you just put


 <trust level="Medium" originUrl="" />

Without the location element

ive made the alterations that you suggested, however, I am not getting a new error:

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a “web.config” configuration file located in the root directory of the current web application. This <customErrors> tag should then have its “mode” attribute set to “Off”.

<!-- Web.Config Configuration File –>

<configuration>
<system.web>
<customErrors mode=“Off”/>
</system.web>
</configuration>

However, I already have <customErrors mode=“Off”/> located within my web.config file.

DId you put the trust element in the system.web element like this


 <system.web>
[.. other configs..]
    <trust level="Medium" originUrl="" />
[..other configs..]
  </system.web>

The customErrors mode may be locked down in the machine config on the server

I entered “<trust level=“Medium” originUrl=”" />" and I saw the following error in local server:
[PolicyException: Required permissions cannot be acquired.]
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) +2738021
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +57
How can I solve this problem?

You modify the code that requires Full trust.