And*_*ers 5 asp.net-mvc wcf ninject
我已经让Ninject MVC与Ninject WCF一起工作以使其工作我在CreateKernel方法中添加了两行
kernel.Bind<ServiceHost>().To<NinjectServiceHost>();
KernelContainer.Kernel = kernel;
Run Code Online (Sandbox Code Playgroud)
注入了依赖项,但没有调用Dispose方法,我已经尝试使用InRequestScope并执行我自己的作用域Func返回OperationContext.Current作为Scope对象,但不调用dispose.
更新2012-09-05 此信息已过时,对于从Nuget Ninject.MV3和Ninject.Extensions.WCF(3.x)下载MVC和WCF,MVC Nuget模板将添加Ninject引导程序NinjectWebCommon.cs并添加支持svc for ninject eddit svc xml(右键单击/查看标记)并将Factory ="Ninject.Extensions.Wcf.NinjectServiceHostFactory"添加到xml节点
我无法回复 Remo 的答案,因为我是 stackoverflow n00b,但“System.Runtime.CompilerServices.ExtensionAttribute”异常的问题是它已从 .net 4.0 中的 System.Core 转移到 .net 4.5 中的 mscorlib。如果安装.net 4.5,问题就会消失。我认为某些东西是与 .net 4.5 混合构建的。https://github.com/ninject/Ninject.Web.Common/issues/3听起来它很快就会修复。至于 Wcf InRequestScope 问题,Remo 今天在 google groups 上给了我一些帮助...“添加一个派生自“Ninject.GlobalKernelRegistrationModule”的新模块并将其加载到内核中。不过,这将在最终版本中修复。”
即类似...
public class MyModule : Ninject.GlobalKernelRegistrationModule<WcfRequestScopeCleanup>
{
}
//And where you load your modules...
kernel.Load<MyModule>();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2021 次 |
| 最近记录: |