tags:

views:

55

answers:

1

Hi everyone,

I am having this problem when I want to implement IoC for sportstore example. The code

public WindsorControllerFactory(){

        container = new WindsorContainer( new XmlInterpreter(new ConfigResource("castle"))

    );



        var controllerTypes= from t in Assembly.GetExecutingAssembly().GetTypes()
                             where typeof(IController).IsAssignableFrom(t)
                             select t;

        foreach (Type t in controllerTypes)


            container.AddComponentLifeStyle(t.FullName, t, LifestyleType.Transient);
    }



    protected override IController  GetControllerInstance(Type controllerType)
          {
           return (IController)container.Resolve(controllerType);
           }





}

The error said that the value cannot be null in the GetControllerInstance

Any help will be appreciated !

Thanks! Naim

A: 

You are getting requests for things without types....

      protected override IController  GetControllerInstance(Type controllerType)
      {
          if (controllerType == null) { 
                return null; 
          }else{
                 return (IController)container.Resolve(controllerType);
           }
       }
Nix