RE: [ninject] Issue with NinjectHttpApplication.Application_Start not firing in a WCF extensions project

858 views
Skip to first unread message

Remo Gloor

unread,
Jul 13, 2012, 3:51:00 AM7/13/12
to nin...@googlegroups.com

Hi Anye

 

NinjectHttpApplication implements Application_Start itself. Therefore you can’t implement it anymore in your global.asax But you can override OnApplicationStarted instead.

 

Remo

 

From: nin...@googlegroups.com [mailto:nin...@googlegroups.com] On Behalf Of Anye Mercy
Sent: Donnerstag, 12. Juli 2012 17:38
To: nin...@googlegroups.com
Subject: [ninject] Issue with NinjectHttpApplication.Application_Start not firing in a WCF extensions project

 

Greetings all,

I have found an issue with the NinjectHttpApplication as used for a WCF service, I am not sure if it is a bug or by design, but something isn't quite right.

In my service before I refactored in Ninject, I had code in the Global.asax Application_Start method to initialize my log4net configuration for logging within the service:
        protected void Application_Start(object sender, EventArgs e)
        {
            XmlConfigurator.Configure(new FileInfo(Server.MapPath("~/Log4Net.config")));
            Log.Error("Called in app_start");  //just here to 'prove' it loaded by creating a log entry in the db.
        }

This worked great up until I changed the Global to inherit from NinjectHttpApplication instead of System.Web.HttpApplication
I noticed my logging code wasn't running in the service anymore. 

To troubleshoot, I moved the code from Application_Start to the CreateKernel() method that I *know* Ninject calls,  as anticipated the logging initialization does execute and logging will occur -- so this verified that nothing messed up the logging configuration itself.

Then I went back to the branch of code right before I added Ninject and doublechecked that the Application_Start was getting called from there just to be sure the issue wasn't there before I added Ninject, and it worked properly as well.

Thus it appears that Application_Start does not fire at all from a NinjectHttpApplication.  If this is by design, then I would ask where we are supposed to put such initialization code that does not relate directly to Ninject (because CreateKernel() certainly isn't the best place for it) in a NinjectHttpApplication.  If it is not by design, then I would be happy to submit a formal bug report on it, since it is probably a bad idea for initialization code to be skipped.  Is the codeplex project the proper place for bug reports or is that somewhere else?

Any ideas on whether this is by design (and in which case where such non-ninject related initializations should occur) or a bug?

Thanks in advance,
Anye

--
You received this message because you are subscribed to the Google Groups "ninject" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ninject/-/t5kPzH1Rr9EJ.
To post to this group, send email to nin...@googlegroups.com.
To unsubscribe from this group, send email to ninject+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ninject?hl=en.

Reply all
Reply to author
Forward
0 new messages