受限信任的共享托管环境中的 MVC 网站
MVC website on a shared hosting environment with restricted trust
我在 ASP.NET 4.6 上有一个简单的 MVC 5 Web 应用程序 运行ning。在 IIS 中本地配置的网站可以正常工作,但是当发布版本发布并上传到共享主机环境时,我收到错误 "Inheritance security rules violated while overriding member"
Server Error in '/' Application.
Inheritance security rules violated while overriding member: 'SimpleInjector.Integration.Web.Mvc.SimpleInjectorDependencyResolver.GetService(System.Type)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Inheritance security rules violated while overriding member: 'SimpleInjector.Integration.Web.Mvc.SimpleInjectorDependencyResolver.GetService(System.Type)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
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:
[TypeLoadException: Inheritance security rules violated while overriding member: 'SimpleInjector.Integration.Web.Mvc.SimpleInjectorDependencyResolver.GetService(System.Type)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.]
我的理解是,MVC Web 应用程序需要 运行 完全信任,但托管服务提供商表示这是不可能的,并且他们在机器级别设置了规则,将应用程序限制为中等信任度。
在代码级别是否有解决此问题的方法,我不敢相信 运行 一个简单的 Web 应用程序需要一个可以配置为具有完全访问权限的专用 Web 服务器框。
是否可以使用另一个不会导致此安全冲突的 IoC 容器?
我们忘记用正确的属性标记 class,现在导致此异常。由于 Microsoft 已弃用对 ASP.NET Web 应用程序的部分信任,我们(Simple Injector 贡献者)可能也不会在该领域投资。换句话说,不要指望我们(很快)修复错误。
要解决此问题,请实施您自己的 SimpleInjectorDependencyResolver
。这样做很简单;这只是您可以从 Simple Injector 的 source code.
复制的几行代码
我在 ASP.NET 4.6 上有一个简单的 MVC 5 Web 应用程序 运行ning。在 IIS 中本地配置的网站可以正常工作,但是当发布版本发布并上传到共享主机环境时,我收到错误 "Inheritance security rules violated while overriding member"
Server Error in '/' Application.
Inheritance security rules violated while overriding member: 'SimpleInjector.Integration.Web.Mvc.SimpleInjectorDependencyResolver.GetService(System.Type)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Inheritance security rules violated while overriding member: 'SimpleInjector.Integration.Web.Mvc.SimpleInjectorDependencyResolver.GetService(System.Type)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
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:
[TypeLoadException: Inheritance security rules violated while overriding member: 'SimpleInjector.Integration.Web.Mvc.SimpleInjectorDependencyResolver.GetService(System.Type)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.]
我的理解是,MVC Web 应用程序需要 运行 完全信任,但托管服务提供商表示这是不可能的,并且他们在机器级别设置了规则,将应用程序限制为中等信任度。
在代码级别是否有解决此问题的方法,我不敢相信 运行 一个简单的 Web 应用程序需要一个可以配置为具有完全访问权限的专用 Web 服务器框。
是否可以使用另一个不会导致此安全冲突的 IoC 容器?
我们忘记用正确的属性标记 class,现在导致此异常。由于 Microsoft 已弃用对 ASP.NET Web 应用程序的部分信任,我们(Simple Injector 贡献者)可能也不会在该领域投资。换句话说,不要指望我们(很快)修复错误。
要解决此问题,请实施您自己的 SimpleInjectorDependencyResolver
。这样做很简单;这只是您可以从 Simple Injector 的 source code.