asp.net - 策略异常 : Required permissions cannot be acquired — what does this error mean

标签 asp.net sqlite iis permissions

尝试加载 aspx 页面时出现此错误:

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

最佳答案

您是否将 Web 应用配置为中等信任并且 SQLite.NET 程序集需要完全信任?

看看是否将此添加到您的 web.config 中可以解决问题:

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

...
</system.web>

或者,如果您已经有了信任标签,请将级别更改为“完全”。

关于asp.net - 策略异常 : Required permissions cannot be acquired — what does this error mean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/596160/

相关文章:

asp.net - 母版页中的可扩展div

c# - asp.net中图像中的字符识别

asp.net - 使用 SignalR 从 Azure 辅助角色向客户端发送消息

ios - 保存到核心数据“ALL 或 ANY 运算符的左侧必须是 NSArray 或 NSSet

c# - 使用 INSERT 语句时如何修复 'SQLite exception, Insufficient parameters supplied to the command'

asp.net - HTTP HEAD 请求超时的未知原因

facebook - IIS 7.5 中的 2 个 SSL、3 个网站、1 个 IP

c# - 在 asp.net c# 中选择开始和结束日期后,在另一个文本框中自动生成天数

actionscript-3 - AIR 和 sqLite : if table exists conditional

自 KB4338419 以来,无法再从经典 ASP 创建 C# COM 对象