2011-12-22 2 views
0

이것은 아마 어리석은 질문입니다! 캐슬 윈저를 IOC로 사용해야하며 MVC로 설정하는 데 문제가 있습니다. 여기 있습니다.로드로 캐슬 윈저 설치자에서 어셈블리

Global.asax에

protected void Application_Start() 
    { 
     AreaRegistration.RegisterAllAreas(); 

     RegisterGlobalFilters(GlobalFilters.Filters); 
     RegisterRoutes(RouteTable.Routes); 
     RegisterCastle(); 

    } 
    private void RegisterCastle() 
    { 
     _container = new WindsorContainer(); 
     _container.Install(FromAssembly.InDirectory(new AssemblyFilter(HttpRuntime.BinDirectory))); 
     ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(_container.Kernel)); 
    } 

컨트롤러 공장 작동하지만 그것에 대해입니다. 나는 설치자와 별도의 프로젝트를 가지고 있는데, 현재 웹 프로젝트의 어셈블리에서 모든 설치 프로그램을로드하는 것처럼 좋아한다.

IWindsorInstaller를 사용하는 DI 프로젝트의 클래스가 전혀로드되지 않습니다. 내가 빠진 것이 있습니까?

Ninject에 우리는

kernel.Load(AppDomain.CurrentDomain.GetAssemblies()); 
+0

이 설치 공공 있습니까 App_Start에 WebActivator를 사용하여 종료 사용할 수 있을까? – PatrickSteele

+0

예 공용 클래스 MyInstaller : IWindsorInstaller –

+0

질문에 대답하기 위해, 아니요. 잘못된 일을하는 것처럼 보이지 않습니다. 작동하지 않는 부분에 대해 자세히 설명해 주시겠습니까? – PatrickSteele

답변

0

내가 기본 매개 변수가없는 생성자

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Mvc; 
using Castle.Facilities.TypedFactory; 
using Castle.MicroKernel; 
using Castle.MicroKernel.Registration; 
using Castle.Windsor; 
using Castle.Windsor.Installer; 
using DFW.Domain.Interfaces; 
using UI.App_Start; 
using UI.Windsor; 

[assembly: WebActivator.PostApplicationStartMethod(typeof(Bootstrapper), "Wire")] 
[assembly: WebActivator.ApplicationShutdownMethod(typeof(Bootstrapper), "DeWire")] 

namespace UI.App_Start 
{ 
    public class Bootstrapper 
    { 
     private static readonly IWindsorContainer Container = new WindsorContainer(); 
     public static void Wire() 
     { 
      //To be able to inject IEnumerable<T> ICollection<T> IList<T> T[] use this: 
      //container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel, true)); 
      //Documentation http://docs.castleproject.org/Windsor.Resolvers.ashx 

      //To support typed factories add this: 
      Container.AddFacility<TypedFactoryFacility>(); 
      Container.Register(Component.For<IServiceFactory>().AsFactory().LifestyleTransient()); 
      //Documentation http://docs.castleproject.org/Windsor.Typed-Factory-Facility.ashx 

      Container.Install(FromAssembly.This()).Install(FromAssembly.Named("APP.Infrastructure.DependencyResolution")); 
      var controllerFactory = new WindsorControllerFactory(Container.Kernel); 
      ControllerBuilder.Current.SetControllerFactory(controllerFactory); 
     } 

     public static void DeWire() 
     { 
      Container.Dispose(); 
     } 
    } 
} 
관련 문제