Ninject model validator causing issues in medium trust

谁说我不能喝 提交于 2019-12-01 08:23:30

问题


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:

"Attempt 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.

来源:https://stackoverflow.com/questions/5037766/ninject-model-validator-causing-issues-in-medium-trust

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!