2
我在一個wcf web服務中使用ninject。該Web服務託管在一個項目中,該項目創建爲「ASP.NET MVC 2空Web應用程序」。使用Ninject.Extensions.Wcf在ASP.NET MVC中託管的Web服務2
它使用Ninject.dll v2和Ninject.Extensions.Wcf.dll v1的參考。
的服務文件的標記是
<%@ ServiceHost
Language="C#"
Debug="true"
Service="wcf_ninject.Service1"
CodeBehind="Service1.svc.cs"
Factory="Ninject.Extensions.Wcf.NinjectServiceHostFactory" %>
在Global.asax從NinjectWcfApplication
public class Global : NinjectWcfApplication
{
protected override IKernel CreateKernel()
{
return new StandardKernel(new WCFNinjectModule());
}
}
繼承與
public class WCFNinjectModule : NinjectModule
{
public override void Load()
{
Bind<IRepository>().To<EFRepository>();
// rest of bindings
}
}
和服務的唯一構造函數是:
public Service1(IRepository repository)
{
_repo = repository;
}
大部分時間工作正常,但不時我得到的錯誤:
"Error activating Service1 More than one matching bindings are available"
但正如說我無法找到一個再現路徑。