Error when deploying ASP.NET MVC NHibernate app to IIS7

最后都变了- 提交于 2019-12-21 20:43:44

问题


I have an Asp.Net MVC application that works in the vs.net development web server. When I publish to IIS7 I get the following error. I have spent many hours and still no solution!

 [NullReferenceException: Object reference not set to an instance of an object.]
   System.Web.PipelineStepManager.ResumeSteps(Exception error) +929
   System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) +91
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +508

Here is the Application_Start

protected void Application_Start()
        {


                ConfigureLogging();


                ComponentRegistrar.RegisterComponents();


                NHibernateSession.InitSqlServer2005(new WebSessionStorage(this), Settings.Default.DefaultConnString);


                CacheManager.InitCaches();

            }
        }

I came late to this application and do not know the best practices of MVC and NHibernate


回答1:


You cant configure nhibernate in application start. I don't exactly know why, but I also had this problem.

You can initialize it in Init(). Also you can see it is done here http://code.google.com/p/sharp-architecture/source/checkout




回答2:


Moving my nhibernate initialization code from Application_Start() to Init() still did not run late enough to fix the error. So I stumbled upon this. The solution I used was not from the original post, but the from first comment by jbland. Basically it moves initialization of nhibernate to occur on the first request.

One thing to note is his code does not give you the context of where webSessionStorage comes from. It is a member variable and must be instantiated in Init().



来源:https://stackoverflow.com/questions/821934/error-when-deploying-asp-net-mvc-nhibernate-app-to-iis7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!