gpt4 book ai didi

c# - 如何将应用程序转换为在中等信任级别下运行?

转载 作者:行者123 更新时间:2023-11-30 18:07:15 26 4
gpt4 key购买 nike

我的 Web 应用程序由多个 Visual Studio 项目组成。它目前在高信任级别(<trust level = "High" />)下运行良好。当我尝试在中等信任级别下运行它时,出现此错误:

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.Security
Exception: Request failed.

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:

[SecurityException: Request failed.]
System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark stackMark, Boolean loadTypeFromPartialName) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark stackMark) +64
System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark stackMark) +58
System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +65
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +342
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +52

Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955

识别问题并将应用程序转换为在中等信任下正常运行的最佳方法是什么?

最佳答案

看起来您正在进行一些动态配置解析 - 您是否在 web.config 中定义了一些自定义配置组 - 反射是中等信任环境中最先关闭的事情之一,而且大多数房东会把它关掉。

如果是这样,我建议转而创建一个明确的 configuration section处理程序(如果可能)。

关于c# - 如何将应用程序转换为在中等信任级别下运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4134621/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com