I have a Foo class that derives from IFoo and then an IFooFactory that I setup via the Ninject Factory Extensions method:
Bind<IFooFactory>().ToFactory()
I then want to make sure any caller classes get an IFoo instance via IFooFactory.Create() rather than just ask for an IFoo in the constructor.
I have tried to create a binding like so:
Bind<IFoo>.To<Foo>
.WhenInjectedInto<IFooFactory>();
Which I then later call fooFactory.Create() on. Unfortunately Ninject isn't happy with the binding and throws a "No matching bindings are available.." exception.
I am also running into the same issue when I have a Foo(string str) constructor whose string dependency is passed in to the factory method via IFooFactory.Create(string str).