PolicyException: Required permissions cannot be acquired — what does this error mean

11,807

Solution 1

Do you have the web app configured as Medium Trust and the SQLite.NET assembly requires Full Trust?

See if adding this to your web.config fixes it:

<system.web>
    <securityPolicy>
        <trust level="Full" />
    </securityPolicy>
...
</system.web>

Or if you already have the trust tag, change the level to Full.

Solution 2

If slolife answer doesn't work, you can also try this from msdn (ASP.NET Trust Levels and Policy Files):

<system.web>
    <securityPolicy>
        <trustLevel name="Full"    policyFile="internal"/>
    </securityPolicy>
</system.web>
Share:
11,807

Related videos on Youtube

Owen Blacker
Author by

Owen Blacker

Technical lead and C# developer. Former founder, director and trustee of Open Rights Group and of mySociety. Queering Wikipedia. Bilingual in French, (rusty) conversational Spanish and German. Dwi'n siarad Cymraeg sygrsiol agus tha mi neach-ionnsachadh Gàidhlig. Pronouns: he/him (or they/them) Technologiste et developpeur en C#. Anciennement fondateur et administrateur des sociétés et des RUPs de Open Rights Group et de mySociety. En plus, suis éditeur des Wikipédias. Je peux contribuer avec un niveau avancé de français, mais plutôt j'utilise l'anglais, ma langue maternelle. Pronom : il (ou iel) Twitter: @owenblacker Facebook: owenblacker.uk LinkedIn: owenblacker Wikipedia: User:OwenBlacker

Updated on June 04, 2022

Comments

  • Owen Blacker
    Owen Blacker about 1 year

    Got this error when trying to load an aspx page:

    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) +2770052
       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 'SQLite.NET, Version=0.21.1869.3794, Culture=neutral, PublicKeyToken=c273bd375e695f9c' 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.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +54
       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
    [ConfigurationErrorsException: Could not load file or assembly 'SQLite.NET, Version=0.21.1869.3794, Culture=neutral, PublicKeyToken=c273bd375e695f9c' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +596
       System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +211
       System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +46
       System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +177
       System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +185
       System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +230
       System.Web.Compilation.BuildManager.CompileGlobalAsax() +49
       System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +462
    [HttpException (0x80004005): Could not load file or assembly 'SQLite.NET, Version=0.21.1869.3794, Culture=neutral, PublicKeyToken=c273bd375e695f9c' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
       System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +57
       System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +612
       System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +644
    [HttpException (0x80004005): Could not load file or assembly 'SQLite.NET, Version=0.21.1869.3794, Culture=neutral, PublicKeyToken=c273bd375e695f9c' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +3465427
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +69
       System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +279
    

Related