I've been trying to get Ninject.Extensions.Conventions for (Ninject 3+) working, with no luck. I boiled it down to a found sample console app, and I can't even get that going. Here's what I have:
class Program
{
static void Main(string[] args)
{
var kernel = new StandardKernel();
kernel.Bind(x => x
.FromThisAssembly()
.SelectAllClasses()
.BindAllInterfaces());
var output = kernel.Get<IConsoleOutput>();
output.HelloWorld();
var service = kernel.Get<Service>();
service.OutputToConsole();
Console.ReadLine();
}
public interface IConsoleOutput
{
void HelloWorld();
}
public class ConsoleOutput : IConsoleOutput
{
public void HelloWorld()
{
Console.WriteLine("Hello world!");
}
}
public class Service
{
private readonly IConsoleOutput _output;
public Service(IConsoleOutput output)
{
_output = output;
}
public void OutputToConsole()
{
_output.HelloWorld();
}
}
}
I've also tried various combos of FromAssembliesMatching, SelectAllTypes, BindDefaultInterfaces, etc. Everything throws the Error activating . No matching bindings are available, and the type is not self-bindable.
Just for sanity, if I do a manual binding with:
kernel.Bind<IConsoleOutput>().To<ConsoleOutput>();
Everything works just fine. So clearly I'm just missing something.