Nie można uzyskać Ninject.Extensions.Conventions to work
Próbowałem uzyskać Ninject.Extensions.Conventions for (Ninject 3+) działający bez powodzenia. Sprowadziłem to do znalezionej przykładowej aplikacji konsoli, a nawet nie mogę tego zrobić. Oto co mam:
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();
}
}
}
Próbowałem też różnych kombinacjiFromAssembliesMatching, SelectAllTypes, BindDefaultInterfacesitd. Wszystko powoduje aktywację błędu. Brak dostępnych pasujących powiązań, a typ nie jest samowiążący.
Tylko dla zdrowia psychicznego, jeśli wykonam ręczne wiązanie z:
kernel.Bind<IConsoleOutput>().To<ConsoleOutput>();
Wszystko działa dobrze. Więc wyraźnie coś mi brakuje.