ComponentNotFoundException 温莎城堡

ComponentNotFoundException Castle Windsor

这是我的Installer.cs:

class Installer : IWindsorInstaller
{
    public void Install(IWindsorContainer container, IConfigurationStore store)
    {
        container
            .Register(Component.For<IDbContext>()
            .ImplementedBy<ApplicationDbContext>()
            .LifeStyle.PerThread
            );

        container
            .Register(Component.For(typeof(IRepository<>))
            .ImplementedBy(typeof(Repository<>))
            .LifeStyle.PerThread
            );

        container
            .Register(Component.For<IServiceReadCity>()
            .ImplementedBy<ServiceReadCity>()
            .LifeStyle.PerThread
            );
    }
}

这是我的Program.cs:

SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
System.Data.Entity.SqlServer.SqlProviderServices.SqlServerTypesAssemblyName = "Microsoft.SqlServer.Types, Version=12.0.0.0, Culture=neutral, PublicKeyToken=898989899898989898";

var container = new WindsorContainer();

container.Install(FromAssembly.This());
IServiceReadCity _cityReadService = container.Resolve<IServiceReadCity>();

var cities = _cityReadService.GetListQuery();

这是控制台应用程序。我得到这个例外:

{"No component for supporting the service Reveal.Domain.Location.Service.Read.IServiceReadCity was found"} At this line :

IServiceReadCity _cityReadService = container.Resolve<IServiceReadCity>();

你能告诉我我做错了什么以及如何解决这个问题吗?谢谢

Windsor 中的安装程序需要 public 易于访问,因为 Windsor 寻找 public 实现 IWindsorInstaller 接口的类型。

制作安装程序 public 应该可以解决问题