当前位置:  开发笔记 > 后端 > 正文

IIS7无法授予最低权限请求

如何解决《IIS7无法授予最低权限请求》经验,为你挑选了2个好方法。

我在使用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

Pat James.. 83

当我使用干净的Windows 7安装重建我的开发机器时,我遇到了类似的问题.在打猎之后,我发现了一个对我有用的解决方案.

在IIS应用程序池高级设置中的"过程模型"下,将"加载用户配置文件"设置为true.

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



1> Pat James..:

当我使用干净的Windows 7安装重建我的开发机器时,我遇到了类似的问题.在打猎之后,我发现了一个对我有用的解决方案.

在IIS应用程序池高级设置中的"过程模型"下,将"加载用户配置文件"设置为true.

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


启动/运行inetmgr.查看应用程序池.右键单击您的应用程序池.选择高级设置.它就是

2> Al Dass..:

我在另一个实例中看到过这个错误,例如,IIS正在通过UNC路径运行应用程序或虚拟路径(即\\svr\share\folder).即使Load User Profile=true我仍然遇到PolicyException错误.它通过运行代码访问安全策略工具(Caspol.exe)来解决,以便为UNC路径添加完全信任.既然我们有64 bit32 bitof,.Net 2.x并且.Net 4.x我在所有四个环境中运行它,如下所示:

%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_LegacySecurityPolicy到truecaspol.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


谢谢你的回答!不容易获得这种特殊的边缘情况知识.
推荐阅读
php
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有