2

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.

Diosney
  • 10,520
  • 15
  • 66
  • 111
Omar
  • 39,496
  • 45
  • 145
  • 213
  • 1
    Opened an issue in github for the Ninject.Web.MVC project. In the meantime, it was pretty easy to swap in Unity 2.0 and it seems to be working well for me in Medium Trust on MVC3.https://github.com/ninject/ninject.web.mvc/issues#issue/15 – Sam Mar 03 '11 at 21:17
  • Find a hosting provider that supports full trust guys. Save several hours of time spent on an issue that has to do with libs not being signed / strong names etc... – Code Jammr Dec 03 '11 at 04:49
  • One of the requirements is to be able to run the app under medium trust. – Omar Dec 03 '11 at 05:55

0 Answers0