Ninject model validator causing issues in medium trust
Using Ninject 2.2 with ASP.NET MVC 3.
I have a controller and some classes located in an external assembly which are registered by loading a NinjectModule
from said assembly.
The models contain some validation properties. It seems Ninject is getting a security exception when a post action is done on an action which takes a model with validation attributes. Below is the exception:
"Attem开发者_如何转开发pt by method 'Ninject.Web.Mvc.Validation.NinjectDataAnnotationsModelValidatorProvider.GetValidators(System Web.Mvc.ModelMetadata, System.Web.Mvc.ControllerContext, System.Collections.Generic.IEnumerable`1)' to access method 'System.Web.Mvc.DataAnnotationsModelValidator.get_Attribute()' failed."
The inner exception simply states: System.Security.SecurityException: Request failed.
However, this works fine in full-trust permissions.
I attempted to create the container in the main assembly via
var kernel = new StandardKernel(new NinjectSettings() { UseReflectionBasedInjection = true });
but the issue still persists.
精彩评论