问题
I've an ASP.NET MVC3 application with Ninject 3. The Ninject 3 was installed using NuGet, and now I'm trying to publish this application on a host that uses medium trust level.
So after I searched on google a little I found an build on the Ninject GoogleCode project website an specific version for medium trust environments, so I downloaded and changed the references on my project, and after I published it I still get the same error.
I already changed the way that I create my kernel and I'm using:
var kernel = new StandardKernel(new NinjectSettings { UseReflectionBasedInjection = true });
And I still get the error.
So anyone already faced this issue and solved it?
回答1:
Try this:
Open this file: MyProjectName\Properties\ AssemblyInfo.cs and then add this line
[assembly: AllowPartiallyTrustedCallers]
In the Global.asax :
INinjectSettings settings = new NinjectSettings
{
UseReflectionBasedInjection = true, // disable code generation for partial trust
InjectNonPublic = false, // disable private reflection for partial trust
InjectParentPrivateProperties = false, // reduce magic
LoadExtensions = false // reduce magic
};
IKernel kernel = new StandardKernel(settings);
来源:https://stackoverflow.com/questions/11989300/running-ninject-3-on-medium-trust-level