Mixed asp.net and ninject 2.0

16 views
Skip to first unread message

Dan Johnson

unread,
Nov 12, 2009, 2:36:42 AM11/12/09
to ninject
Hi,
I'm trying to get ninject working in a mixed (mvc and webforms)
asp.net app.

NinjectHttpApplication exists in both ninject.web and ninject.web.mvc,
and my app is using the one in ninject.web.mvc
But this falls over on the call to KernelContainer within my master
page (using MasterPageBase).

Any thoughts?

(I'm on the cusp of creating a frankenstein Ninject.web.mixed or
similar to support KernelContainer in the mvc NinjectHttpApplication.)

Dan

Ian Davis

unread,
Nov 12, 2009, 12:39:42 PM11/12/09
to nin...@googlegroups.com
Are you getting a null reference exception from using a KernelContainer? Can you post a sample project with your error or explain a little bit more?
--
Ian Davis
http://disassembla.net

Dan Johnson

unread,
Nov 20, 2009, 10:45:08 AM11/20/09
to ninject
Yes,
Ninject.Web.NinjectHttpApplication Application_Start has
KernelContainer.Kernel = CreateKernel();
but Ninject.Web.Mvc.NinjectHttpApplication does not.

So when PageBase calls
KernelContainer.Inject( this );
during OnInit (via RequestActivation)
there's a null reference exception.

It looks like I'm having to use NinjectServiceLocator to create
objects in my web forms, instead of using Ninject.Web and the xyzBase
classes.

Ian.F...@gmail.com

unread,
Nov 20, 2009, 11:02:28 AM11/20/09
to ninject
Ninject.Web.Mvc has its own kernel container I believe, you need to initialize it manually since you are not using the application from Ninject.Web.Mvc.
> --
>
>
>
> You received this message because you are subscribed to the Google Groups "ninject" group.
>
> 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=.
>
>
>
>
>
Reply all
Reply to author
Forward
0 new messages