忍者+ .NET 4 +集成管道导致 NullReferenceException
我已经在 ASP.NET 4.0 项目(不是 MVC)中配置了 Ninject 2,但是当我将该项目部署到 IIS 主机时,它崩溃并出现以下错误:
System.NullReferenceException: Object reference not set to an instance of an object.
[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.PipelineModuleStepContainer.GetEventCount(RequestNotification notification, Boolean isPostEvent) +30
System.Web.PipelineStepManager.ResumeSteps(Exception error) +1481
System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) +132
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +709
我用普通 ASP.net Web 应用程序再次测试了它,并得到了相同的崩溃使用以下代码:
protected override IKernel CreateKernel()
{
return Container;
}
private IKernel Container
{
get
{
IKernel kernel = new StandardKernel(new SiteModule());
var module = new OnePerRequestModule();
module.Init(this);
return kernel;
}
}
还有其他人让 Ninject 与 ASP.net 4 一起使用吗?
[更新:2010.11.03]
经过一些研究后,它似乎可能与 OnePerRequestModule() 模块有关,但删除它似乎并不能解决我根据 这个问题。
I have configured Ninject 2 in an ASP.NET 4.0 project (not MVC) however when I deploy the project to an IIS host it crashes with the following:
System.NullReferenceException: Object reference not set to an instance of an object.
[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.PipelineModuleStepContainer.GetEventCount(RequestNotification notification, Boolean isPostEvent) +30
System.Web.PipelineStepManager.ResumeSteps(Exception error) +1481
System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) +132
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +709
I have tested this again with a vanilla ASP.net Web Application and get the same crash with the following code:
protected override IKernel CreateKernel()
{
return Container;
}
private IKernel Container
{
get
{
IKernel kernel = new StandardKernel(new SiteModule());
var module = new OnePerRequestModule();
module.Init(this);
return kernel;
}
}
Has anyone else got Ninject working with ASP.net 4?
[UPDATE: 2010.11.03]
After doing some research it appears it may be something to do with the OnePerRequestModule() module, removing this however doesn't seem to resolve the problem I added it due at the suggestion of this question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Ninject 2 中,您使用 Ninject.Web 扩展 (在此处查看完整的设置),并且不要像您在
OnePerRequestModule
等处那样进行任何显式配置。您不执行任何网络操作.config 内容要么 IIRC (我正在使用MVC ,而你不在那里)
In Ninject 2, you use the Ninject.Web extension (see the complete set here) and dont do any explicit config as you have here around
OnePerRequestModule
etc.You don't do any web.config stuff either IIRC (I'm using the MVC one and you don't there)