Tôi muốn viết kiểm tra để xác minh ánh xạ trong windsor lâu đài. Tôi đang sử dụng ASP MVC2 nơi tôi đang sử dụng windsor lâu đài để ánh xạ kho của tôi.Thử nghiệm ánh xạ chibernate Castle Windsor trong httpModules không được đăng ký
Tôi đã đọc bài viết này:
và dựa trên này tôi đã tạo ra MS thử nghiệm
[TestMethod()]
public void GetContainerTest()
{
MooseMvc.Infrastructure.DependencyInjectionInitialiser target = new MooseMvc.Infrastructure.DependencyInjectionInitialiser(); // TODO: Initialize to an appropriate value
IWindsorContainer container = target.GetContainer();
foreach (IHandler assignableHandler in container.Kernel.GetAssignableHandlers(typeof(object)))
{
container.Resolve(assignableHandler.ComponentModel.Service);
}
}
tôi Các dữ liệu cho target.getcontainer() thực hiện
this._windsorContainer.Register(Component.For<TInterfaceType>()
.ImplementedBy(typeof(TConcreteType)).LifeStyle.PerWebRequest);
Tôi nhận được tin nhắn là fol mức thấp:
Looks like you forgot to register the http module
Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule Add '<add
name="PerRequestLifestyle"
type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule,
Castle.Windsor" />' to the <httpModules> section on your web.config.
If you're running IIS7 in Integrated Mode you will need to add it to
<modules> section under <system.webServer>
Cảm ơn! Chính xác những gì tôi cần. –
Haha, một vài tháng sau, tôi đến cùng một vấn đề trong một dự án khác và nó giải quyết nó cho tôi một lần nữa. Cảm ơn! PS Chỉ cần nhớ để thực hiện đăng ký sự kiện ComponentModelCreated này trước bất kỳ trình cài đặt hoặc Đăng ký cuộc gọi nào! –