Question

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

Was it helpful?

Solution

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

OTHER TIPS

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().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top