【问题标题】:IIS7 Failed to grant minimum permission requestsIIS7 无法授予最低权限请求
【发布时间】:2010-12-23 05:46:09
【问题描述】:

我在使用 FileHelpers.dll 时收到此错误,但我的 IIS 设置为完全信任级别,因此不应该这样

这是完整的堆栈跟踪:

    [PolicyException: Required permissions cannot be acquired.]
       System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) +10238142
       System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +97

    [FileLoadException: Could not load file or assembly 'FileHelpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3e0c08d59cc3d657' 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) +416
       System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +166
       System.Reflection.Assembly.Load(String assemblyString) +35
       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +190

    [ConfigurationErrorsException: Could not load file or assembly 'FileHelpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3e0c08d59cc3d657' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11207304
       System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +388
       System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +232
       System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +48
       System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +210
       System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +76
       System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +283
       System.Web.Compilation.BuildManager.CompileGlobalAsax() +50
       System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +676

    [HttpException (0x80004005): Could not load file or assembly 'FileHelpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3e0c08d59cc3d657' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
       System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +76
       System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +1012
       System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +1025

[HttpException (0x80004005): Could not load file or assembly 'FileHelpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3e0c08d59cc3d657' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11301302
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +88
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4338644

【问题讨论】:

    标签: iis permissions


    【解决方案1】:

    当我使用干净的 Windows 7 安装重建我的开发机器时,我遇到了类似的问题。在四处寻找后,我发现了一个适合我的解决方案。

    在您的 IIS 应用程序池高级设置中,在“进程模型”下,将加载用户配置文件设置为 true。

    还有一些其他的事情需要检查,比如你的信任级别,但没有一个适用于我(我的开发机器上已经完全信任了)。将应用程序池设置为加载用户配置文件修复了它。

    【讨论】:

    • 这个过程模型在哪里?
    • 启动/运行 inetmgr。查看应用程序池。右键单击您的应用程序池。选择高级设置。在那里
    【解决方案2】:

    我们在 Windows 2008 R2 中遇到了类似的问题,我们的应用程序在 64 位模式下可以正常工作,但是当切换到 32 位模式时将停止运行并抛出权限错误,结果证明,在 IIS7 中的高级设置 >> 进程模型下>> “身份”设置已默认切换为“应用程序池身份”,可能需要更改为“网络服务”才能在 32 位模式下工作。

    我们做到了,现在我们正在顺利地哼唱。认为这个信息的花絮可能是每个人都指向文件夹权限的原因,因为从技术上讲,这是一个文件夹权限问题。但更改是在 IIS 中,而不是文件夹本身的安全设置。

    【讨论】:

    • Samuel 描述的对我有用的东西......只是添加一件事,这是应用程序池的高级设置......
    【解决方案3】:

    我在另一个实例中看到此错误,例如,IIS 通过 UNC 路径(即\\svr\share\folder)运行应用程序或虚拟路径。即使Load User Profile=true 我仍然收到 PolicyException 错误。通过运行Code Access Security Policy Tool (Caspol.exe) 为UNC 路径添加完全信任已解决该问题。由于我们有.Net 2.x.Net 4.x 中的64 bit32 bit,所以我在所有四个环境中运行它,如下所示:

    %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\caspol.exe -pp off -m -ag 1 -url "file:////\\svr\share\folder\*"   FullTrust -exclusive on
    %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\caspol.exe -pp off -m -ag 1 -url "file:////\\svr\share\folder\*"   FullTrust -exclusive on
    %SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\caspol.exe -pp off -m -ag 1 -url "file:////\\svr\share\folder\*"   FullTrust -exclusive on
    %SystemRoot%\Microsoft.NET\Framework64\v4.0.30319\caspol.exe -pp off -m -ag 1 -url "file:////\\svr\share\folder\*"   FullTrust -exclusive on
    

    一些注意事项:

    • 对于.Net 4.x,请务必启用NetFx40_LegacySecurityPolicytrue,否则caspol.exe 命令将无法按预期工作。
    • 不要不要为给定环境添加带有caspol.exe 的重复条目。运行以下命令以查看您的条目:

      %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\caspol.exe -a -lg %SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\caspol.exe -a -lg %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\caspol.exe -a -lg %SystemRoot%\Microsoft.NET\Framework64\v4.0.30319\caspol.exe -a -lg

    【讨论】:

      【解决方案4】:

      这似乎是一个通用程序集不会加载错误。我感谢所有其他帖子,因为它们成为可能的错误来源列表。

      我又找到了一个。我尝试了以上所有方法都没有成功。我终于意识到我正在从 Visual Studios Express 2008 发布 Web 应用程序,并且构建配置为“调试”。将构建配置更改为“发布”后,Web 应用程序开始工作。

      具体情况: Visual Studios Express 2008 将文件移动到 Win 2008 R2 服务器上的 IIS7.5。

      【讨论】:

        【解决方案5】:

        在您的 IIS 6.0 应用程序池高级设置中,在“进程模型”下,将加载用户配置文件设置为 true。

        还有一些其他的事情需要检查,比如你的信任级别,但没有一个适用于我(我的开发机器上已经完全信任了)。将应用程序池设置为加载用户配置文件修复了它。

        帮助解决

        在 iis 中无法获取所需的权限来解决它..

        【讨论】:

          【解决方案6】:

          我有类似的问题,我通过以下步骤解决了这个问题:

          1. 转到 IIS。
          2. 右键单击网站文件夹,查看它的应用程序池。
          3. 右键单击应用程序池并转到高级设置。
          4. 在流​​程模型部分将load user profile 设置为true

          【讨论】:

            【解决方案7】:

            她的问题属于使用 ddl 不信任 SharePoint 解决问题:

            1. 打开 IIS
            2. 点击.net最真实的关卡
            3. 选择完整(内部)

            【讨论】:

              【解决方案8】:

              老问题,但我的答案已被删除,因为我只发布了一个链接。

              也许你会得到这个错误: 错误:

              无法加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.Configuration.Design,Version=2.0.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。未能授予最低权限请求。 (HRESULT 异常:0x80131417)

              发生此错误是因为本地计算机的默认信任级别是完全信任,但在网络共享中不是。

              因此,要远程编译您的应用程序,您必须: 转到控制面板->管理工具->Microsoft .NET Framework 2.0 配置 打开我的电脑->运行时安全策略->机器>代码组>所有代码>新建(右键出现菜单选择新建 )

              下图中的 URL 字段是共享文件夹的路径,在这种情况下,您可以选择 Strong Names(for .exe or .dll) etc

              点击完成,你就可以编译你的应用了!!

              https://medium.com/@marcoscavaleiro/failed-to-grant-minimum-permission-requests-7245cf694ebd

              【讨论】:

                【解决方案9】:

                这是一个安全/信任问题。在 Windows 资源管理器中打开 DLL 的属性。它可能被标记为被阻止,因为它是从互联网上下载的。转到属性并单击“取消阻止”按钮,问题可能会解决。

                【讨论】:

                • 就我而言,正是因为这个而发生的。谢谢!
                • 你救了我的命,这对我有用……VS 2019 社区版 - 谢谢!!!
                猜你喜欢
                • 2015-07-24
                • 2023-03-30
                • 2017-10-30
                • 1970-01-01
                • 2021-07-02
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多