Hi,
This is from a very good book by Steven Sanderson
I am trying to follow the chapter 4 and trying to setup IOC on my mvc code from the code sample of the book but its not working.
I follow the code from page 97 to page 101 where I set up Inversion of Control and run the code but I get the following error.
A dialog box opens trying to search the following file:
c:\TeamCity\buildAgent\work\1ab5e0b25b145b19\src\Castle.Windsor\Windsor\WindsorContainer.cs
It seems like controllertype is null in the following line of code:
protected override IController GetControllerInstance(
System.Web.Routing.RequestContext requestContext,
Type controllerType)
{
return (IController)container.Resolve(controllerType);
}
The exception happens at the above return statement saying " {"Value cannot be null.\r\nParameter name: service"}"
This happens to be in WindsorContainerFactory.
Routes looks as follows:
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Products", action = "List", id = ""} // Parameter defaults
);
}
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory());
}
}
Please help..
Thanks..