If you request an unbound object from NInject, then the default behaviour is (if a suitable constructor is available) appears to be to create an instance of the appropriate obje
The following is a better, more direct way of removing the SelfBindingResolver
, without assuming that the DefaultValueBindingResolver
is the only other IMissingBindingResolver
component:
kernel.Components.Remove<IMissingBindingResolver, SelfBindingResolver>();
It's possible the Remove<T, TImplementation>()
method was only added in a recent version of Ninject, but this works for me using Ninject 3.2.2.0.
Remove the SelfBindingResolver
from the kernel components after creation:
kernel.Components.RemoveAll<IMissingBindingResolver>();
kernel.Components.Add<IMissingBindingResolver, DefaultValueBindingResolver>();