我正在尝试将Ninject 2.0与Asp .Net 3.5 Web应用程序一起使用。以下是我使用的DLL和它们的版本。
- Ninject.dll - v2.0.0.0
- Ninject.Extensions.Logging.dll v2.0.0.0
- Ninject.Web.dll v1.0.0.0
在我的global.ascx.cs文件中,我有以下方法。
protected override IKernel CreateKernel()
{
IKernel kernel = new StandardKernel();
kernel.Bind<IDataAccess>().To<DataAccessEntBlock>().InSingletonScope();
return kernel;
}
当我运行应用程序时,我遇到了以下错误。
Error activating ILoggerFactory
No matching bindings are available, and the type is not self-bindable.
Activation path:
1) Request for ILoggerFactory
Suggestions:
1) Ensure that you have defined a binding for ILoggerFactory.
2) If the binding was defined in a module, ensure that the module has been loaded into the kernel.
3) Ensure you have not accidentally created more than one kernel.
4) If you are using automatic module loading, ensure the search path and filters are
正确。
虽然我没有尝试注册Logger,但我仍然不理解为什么它似乎在尝试创建自己。我该如何解决这个错误?我是否需要使用Ninject的扩展Logger?
谢谢 GK