public class WebAppHost {
public WebAppHost(IAppSettings appSettings) {
this._appSettings = appSettings;
}
public Configuration(IAppBuilder appBuilder) {
if(this._appSettings.StartApi)
appBuilder.UseWebApi();
}
}
public class AppContext {
public static void Start(string[] args) {
DynamicModule.Utility.RegisterModule(typeof(OnePerRequestHttpModule));
DynamicModule.Utility.RegisterModule(typeof(NinjectHttpModule));
_bootstrapper.Initialize(CreateKernel);
WebApp.Start<WebAppHost>("uri");
}
private static IKernel CreateKernel() {
var kernel = new StandardKernel();
kernel.bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
kernel.bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
RegisterServices(kernel);
return kernel;
}
private static void ReigsterServices(IKernel kernel) {
kernel.Bind<IAppSettings>().To<AppSettings>()
.InRequestScope();
}
}
When I try to access the resolved IAppSettings, it's always null and a null reference exception occurs. What could be wrong?