下面是 NinjectHttpApplication 配置..
public class MvcApplication : NinjectHttpApplication
{
public MvcApplication()
{
Error += NinjectWebsiteApplication_Error;
}
}
protected override IKernel CreateKernel()
{
var kernel = new StandardKernel();
kernel.Load<ApplicationConfig>();
return kernel;
}
void NinjectWebsiteApplication_Error(object sender, System.EventArgs e)
{
ILogger _iLogger = **//How to get instance of Applogger here from Ninject kernel..**
}
下面是 ApplicationConfig 类...
public class ApplicationConfig : NHibernateNinjectModule
{
public ApplicationConfig()
{
//other settings such as ddl script generation is present here
}
public override void Load()
{
base.Load();
Bind<ILogger>().To<AppLogger>().InSingletonScope();
}
}