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

发布于 2024-10-01 17:23:13 字数 1233 浏览 0 评论 0原文

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

安全异常

描述:应用程序试图执行安全策略不允许的操作。要授予此应用程序所需的权限,请联系您的系统管理员或在配置文件中更改应用程序的信任级别。

异常详细信息:System.Security.Security
异常:请求失败。

来源错误:

执行当前 Web 请求期间生成未处理的异常。有关异常来源和位置的信息可以使用下面的异常堆栈跟踪来识别。

堆栈跟踪:

[SecurityException:请求失败。]
System.RuntimeTypeHandle._GetTypeByName(字符串名称,布尔值 throwOnError,布尔值ignoreCase,布尔值反射,StackCrawlMark stackMark,布尔值loadTypeFromPartialName)+0
System.RuntimeTypeHandle.GetTypeByName(字符串名称,布尔值 throwOnError,布尔值ignoreCase,布尔值反射,StackCrawlMark stackMark)+64   
System.RuntimeType.PrivateGetType(字符串类型名称,布尔值 throwOnError,布尔值ignoreCase,布尔值反射,StackCrawlMark stackMark)+58   
System.Type.GetType(字符串类型名称,布尔值 throwOnError,布尔值忽略大小写)+65   
System.Web.Compilation.BuildManager.GetType(字符串类型名称,布尔值 throwOnError,布尔值忽略大小写)+342   
System.Web.Configuration.ConfigUtil.GetType(字符串类型名称,字符串属性名称,ConfigurationElement configElement,XmlNode节点,布尔checkAptcaBit,布尔ignoreCase)+52

版本信息:Microsoft .NET Framework 版本:2.0.50727.4952; ASP.NET版本:2.0.50727.4955

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

My web application is composed of several Visual Studio projects. It currently runs fine under high trust level (<trust level = "High" />). When I try to run it under medium trust level, I get this error:

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

What is the best way to identify the problem and convert the application to run properly under medium trust?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天煞孤星 2024-10-08 17:23:13

看起来您正在进行一些动态配置解析 - 您的 web.config 中定义了一些自定义配置组 - 反射是在中等信任环境中首先关闭的事情之一,大多数主机都会离开关掉它。

如果是这样,我建议转而创建一个显式的 配置部分 处理程序(如果可能)。

It looks like you've got some dynamic configuration resolution going on - have you got some custom Config Groups defined in your web.config - reflection is one of the first things that gets turned off in a medium trust environment, and most hosts will leave it off.

If so, I'd suggest moving over to creating an explicit configuration section handler if possible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文