这就是我的 Application_Start 的外观:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
_container.Register(Component.For<IWindsorContainer>()
.Instance(_container),
Component.For<IView, IViewPageActivator>()
.ImplementedBy<RazorView>(),
Component.For<IFilterProvider>()
.ImplementedBy<WindsorFilterAttributeFilterProvider>(),
Component.For<IControllerFactory>()
.ImplementedBy<WindsorControllerFactory>(),
Component.For<ControllerContext>()
.ImplementedBy<ControllerContext>()
);
_container.Register(
AllTypes.Of<IController>()
.FromAssembly(Assembly.GetExecutingAssembly())
.Configure(c => c.LifeStyle.Transient)
);
然而,当尝试运行解决方案时,我收到以下错误:
Can't create component 'System.Web.Mvc.RazorView' as it has dependencies to be
satisfied.
System.Web.Mvc.RazorView is waiting for the following dependencies:
Keys (components with specific keys)
- viewPath which was not registered.
- layoutPath which was not registered.
- runViewStartPages which was not registered.
- viewStartFileExtensions which was not registered.
如何设置容器以便它可以在运行时动态获取所需信息?正如我假设的那样,至少每个控制器的 viewPath 都会发生变化。