for type in AllTypesBased of IController("Practicum.Web"):
component type.FullName, type:
lifestyle Transient
Can any of you Binsor/ASP.Net MVC gurus help with a problem I'm having.
I've got a very simple boo script that runs through the MVC app and
another dll that holds services etc.
when the web-site runs i keep getting a "No component for supporting
the service Practicum.Web.Controllers.LoginController" error. I've
looked at the ControllerBuilder and both the login controller and its
dependancies are in there but it is not resolving it at all.
The code im using is as follows:
//global.asax.cs file
public class MvcApplication : System.Web.HttpApplication
{
public IControllerFactory Factory;
public IWindsorContainer Container;
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
// Route name
"{controller}/{action}/{id}",
// URL with parameters
new { controller = "Login", action = "Login", id = ""
} // Parameter defaults
);
}
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
Container = new WindsorContainer();
BooReader.Read(Container, "Support files/windsor.boo");
Factory = new WindsorControllerFactory(Container);
ControllerBuilder.Current.SetControllerFactory(Factory);
}
}
/////boo script
import Practicum.Web
import System.Web.Mvc
import Practicum.Core
import System
import System.Reflection
import Castle.Windsor
import Castle.Core
practicumweb = Assembly.Load("Practicum.Web")
for type in practicumweb.GetTypes():
if typeof(System.Web.Mvc.Controller).IsAssignableFrom(type):
Component(type.Name, System.Web.Mvc.Controller, type)
practicumcore = Assembly.Load("Practicum.Core")
for type in practicumcore.GetTypes():
if typeof(Practicum.Core.Service.IService).IsAssignableFrom(type)
and type is not typeof(Practicum.Core.Service.IService):
Component(type.Name, Practicum.Core.Service.IService, type)
//default page load on the Default.aspx.cs file in site root. I havn't
changed this at all
public void Page_Load(object sender, System.EventArgs e)
{
HttpContext.Current.RewritePath(Request.ApplicationPath);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
}
//login controller
[HandleError]
public class LoginController : Controller
{
private readonly IService _service;
public LoginController (IService CustomService)
{
_service = CustomService;
}
public ActionResult Login()
{
return View();
}
}
The CustomService currently has nothing in it and derives from IService.
If anyone can help that would be great.
Cheer
Colin G
--
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
-Martin Fowler et al, Refactoring: Improving the Design of Existing Code