当我将DotNetOpenAuth dll放入我的/ bin目录时,我的应用程序将无法使用以下堆栈跟踪运行。有没有人有这个图书馆的经验?我已经浏览了他们的文档,并怀疑我没有正确部署它。我的网络应用程序应该在我的本地计算机上完全信任地运行,因此不清楚它无法获取它所要求的权限。
谢谢! 汤姆
[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 'DotNetOpenAuth, Version=3.3.1.9337, Culture=neutral, PublicKeyToken=2780ccd10d57b246' 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 'DotNetOpenAuth, Version=3.3.1.9337, Culture=neutral, PublicKeyToken=2780ccd10d57b246' 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.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +11196482
System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +185
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +551
[HttpException (0x80004005): Could not load file or assembly 'DotNetOpenAuth, Version=3.3.1.9337, Culture=neutral, PublicKeyToken=2780ccd10d57b246' 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 'DotNetOpenAuth, Version=3.3.1.9337, Culture=neutral, PublicKeyToken=2780ccd10d57b246' 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
答案 0 :(得分:4)
奇怪的是,我发现解决方案与this有关。
应用程序池标识有一个 属性称为加载用户配置文件 当此值为false时,您可以 收到上面显示的错误。至 解决此问题,打开IIS管理器和 导航到您的应用程序池 身份。你会找到的设置 “高级设置”窗口。更改 它是真的。
我发现当我将其设置为true时,库再次开始工作。当我将其重新设置为false时,即使在服务重新启动和应用程序池回收后,它仍继续工作。所以,奇怪的是现在一切都好看。
答案 1 :(得分:1)
看起来Code Access Security不会考虑以完全信任的方式加载DotNetOpenAuth。实际上,它只需要中等信任,但这里是DotNetOpenAuth请求的最小权限列表:
[assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution = true)]
[assembly: WebPermission(SecurityAction.RequestMinimum, ConnectPattern = @"http://.*")]
[assembly: WebPermission(SecurityAction.RequestMinimum, ConnectPattern = @"https://.*")]
第二对夫妇可能会从某些中等信任配置中丢失,但如果您以完全信任的方式运行,那么它应该是一个非问题。
尝试将<trust level="Full"/>
添加到其<system.web>
部分中的web.config文件中,看看是否有帮助,或者生成错误以帮助您缩小问题范围。