Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Ninject 2, how do I have two Kernels with different settings share bindings?

I have a single Ninject 2 Kernel for my application which contains all bindings. One section of the application needs to have different settings on the Kernel than the rest of the application, but needs the same bindings (that portion is for NHibernate and needs InjectNonPublic = true and the InjectAttribute set). How can a make a Kernel that shares bindings with the current kernel but has different settings?

I believe that in other IOC containers this is would be achieved with a "nested container", however I don't see any support for nested containers in Ninject?

like image 337
Jeff Walker Code Ranger Avatar asked Jan 28 '26 20:01

Jeff Walker Code Ranger


1 Answers

Have you tried the Ninject.Extensions.ChildKernel extension?

like image 133
Martin Owen Avatar answered Jan 31 '26 08:01

Martin Owen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!