Emma Middlebrook
Emma Middlebrook

Reputation: 876

MVC website on a shared hosting environment with restricted trust

I have a simple MVC 5 web application running on ASP.NET 4.6. The website when configured locally in IIS works, however when the release build is published and uploaded to the shared hosting environment I get an error "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.]

My understanding is that MVC web applications need to run with full trust but the hosting provider has indicated that this is not possible and that they have a rule set at machine level that restricts applications to medium trust.

Is there a workaround for this at a code level, I can't believe that to run a simple web application you would need a dedicated web server box that can be configured to have full access.

Is there another IoC container that can be used that doesn't cause this security conflict?

Upvotes: 2

Views: 252

Answers (1)

Steven
Steven

Reputation: 172676

We forget to mark that class with the correct attribute, which now causes this exception. Since Microsoft has deprecated partial trust in ASP.NET web applications, we (the Simple Injector contributors) will probably not invest in this area as well. In other words, don't expect us to fix the bug (soon).

To solve this issue, implement your own SimpleInjectorDependencyResolver. Doing this is trivial; it's just a few lines of code that you can copy from Simple Injector's source code.

Upvotes: 1

Related Questions