tôi có mã trong global.axax tôi:Lâu đài Windsor không thể tìm thấy các trình cài đặt trong hội đồng
protected void Application_Start()
{
WindsorContainer = new WindsorContainer();
WindsorContainer.Install(FromAssembly.InDirectory(new AssemblyFilter(AppDomain.CurrentDomain.RelativeSearchPath)));
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(WindsorContainer.Kernel));
//...
}
Khi tôi gỡ lỗi global.asax, mã FromAssembly.InDirectory(newAssemblyFilter(AppDomain.CurrentDomain.RelativeSearchPath))
tìm tất cả các dự án dll của tôi (có 7 dll của). 3 trong số họ có thực hiện giao diện IWindsorInstaller
, ví dụ:
class WindsorInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
var services = AllTypes.FromThisAssembly().Where(type => type.Name.EndsWith("Service"));
container.Register(services
.WithService.DefaultInterfaces()
.Configure(c => c.LifestyleTransient()));
container.Register(Component.For<ISession>().ImplementedBy<AspnetSession>().
LifeStyle.Transient);
container.Register(Component.For<ICache>().ImplementedBy<AspnetCache>().
LifeStyle.Transient);
}
}
Nhưng khi tôi đặt breakpoint, nó chỉ là 1 trình cài đặt gọi, 2 khác đã bỏ qua. Thật buồn cười, nhưng tôi có một dự án đang hoạt động khác với mã tôi đã sao chép.
Ôi trời ơi! Nó rất ngu ngốc sai lầm :) Cảm ơn! –
Xảy ra cho tất cả chúng ta, mọi lúc :) – Marijn