忍者+ .NET 4 +集成管道导致 NullReferenceException

发布于 2024-09-30 15:01:14 字数 1296 浏览 11 评论 0原文

我已经在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恍梦境° 2024-10-07 15:01:14

在 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文