2011-12-22 21 views
0

これはおそらくばかげた質問です!私はCastle Windsorを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)); 
    } 

コントローラの工場が動作しますが、それはそれについてです。私は私のインストーラと別のプロジェクトを持っているだけでなく、私はそれが現在のWebプロジェクトのアセンブリから任意のインストーラを読み込むのが好きです(私はそこに何かを知っている必要があります)。

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(); 
     } 
    } 
} 
関連する問題