我正在开发一个 asp.net 3.5 Web 应用程序,它在我的本地 IIS 服务器上完美运行,但是在将它发布到托管(1and1)环境时给我带来了很多麻烦。
加载 web.config 时,“System.Security.Policy.PolicyException:无法获取所需的权限”。抛出异常。堆栈跟踪表明这是由我使用 Castle.Windsor 框架引起的:
[PolicyException: 无法获取所需权限。]
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) +7606231
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +57[FileLoadException:无法加载文件或程序集“Castle.Windsor,版本=3.0.0.0,文化=中性,PublicKeyToken=407dd0808d44fbdc”或其依赖项之一。未能授予最低权限请求。(HRESULT 异常:0x80131417)]
System.Reflection.Assembly._nLoad(AssemblyName 文件名,字符串 codeBase,证据 assemblySecurity,程序集 locationHint,StackCrawlMark 和 stackMark,布尔 throwOnFileNotFound,布尔 forIntrospection)+0 System.Reflection.Assembly.nLoad(AssemblyName 文件名,字符串 codeBase、证据 assemblySecurity、Assembly locationHint、StackCrawlMark& stackMark、布尔 throwOnFileNotFound、Boolean forIntrospection) +43
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean for Introspection) +127
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean for Introspection) +142 System.Reflection.Assembly。加载(字符串程序集字符串)+28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串程序集名称,布尔星指令)+46[ConfigurationErrorsException:无法加载文件或程序集“Castle.Windsor,版本=3.0.0.0,文化=中性,PublicKeyToken=407dd0808d44fbdc”或其依赖项之一。未能授予最低权限请求。(来自 HRESULT 的异常:0x80131417)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 assemblyName,布尔 starDirective)+613
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +54 System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +232
System.Web.Compilation.BuildManager.CompileGlobalAsax() +51
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +337[HttpException(0x80004005):无法加载文件或程序集“Castle.Windsor,版本=3.0.0.0,文化=中性,PublicKeyToken=407dd0808d44fbdc”或其依赖项之一。未能授予最低权限请求。(HRESULT 异常:0x80131417)]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +58 System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +512 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +729[HttpException(0x80004005):无法加载文件或程序集“Castle.Windsor,版本=3.0.0.0,文化=中性,PublicKeyToken=407dd0808d44fbdc”或其依赖项之一。未能授予最低权限请求。(HRESULT 异常:0x80131417)] System.Web.HttpRuntime.FirstRequestInit(HttpContext context)+8921851
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)+85 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext context)+333
由于托管环境的限制,我在调查此问题方面非常有限 - 特别是我无法查看 machine.config 和 IIS 配置。我肯定知道的一个事实是它运行在 2.0.50727.5456 框架上......托管服务商的客户服务既不称职也不愿意提供帮助,所以我必须自己做。
任何有关如何深入研究原因或如何简单解决此问题的建议都非常感谢。