在中等信任级别运行Ninject 3 [英] Running Ninject 3 on medium trust level
问题描述
我已经与Ninject 3. Ninject 3使用的NuGet安装了ASP.NET MVC3应用程序,现在我试图使用中等信任级别的主机上发布该应用程序。
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.
所以,我搜索了谷歌后一点,我发现了Ninject谷歌code项目的网站上建立一个特定版本为中等信任环境,所以我下载并改变了我的项目的引用,之后我发表它,我仍然得到同样的错误。
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 });
和我仍然得到错误。
因此,任何人已经面临这个问题,并解决它?
So anyone already faced this issue and solved it?
推荐答案
试试这个:
打开此文件:MyProjectName \\属性\\ 的AssemblyInfo.cs
然后加入这一行
Open this file: MyProjectName\Properties\ AssemblyInfo.cs and then add this line
[汇编:AllowPartiallyTrustedCallers]
在Global.asax中:
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);
这篇关于在中等信任级别运行Ninject 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!