On Tue, Oct 21, 2008 at 2:22 PM, Colin Gemmell <pythonandchips@...> wrote:
Cheers Chris that sorted the problem (just as my boss came in perfect
timing). Buy you a pint for that.
Colin G
--- In glasgow_altdotnet_usersgroup@yahoogroups.com, "Chris Canal"
<dhtmlgod@...> wrote:
>
> And more, make sure you set the lifestyle of controllers to
Transient. The
> default is Singleton, and will break with Mvc. I mention it because
your
> not doing that in the boo file, of course you could be using an
attribute.
> If so, just tell me to shut up :o)
>> On Tue, Oct 21, 2008 at 2:13 PM, Chris Canal <dhtmlgod@...> wrote:
>
> > And just so you know what you where doing wrong:
> >
> > Component(type.Name, *System.Web.Mvc.Controller*, type)
> >
> > The controllers where being registed with the service type of
Controller
> > with the above bolded seciotn, so trying to resolve
LoginController will not
> > work. To make your code work, it would need to be this:
> >
> > Component type.Name, type
> >
> >> > On Tue, Oct 21, 2008 at 2:10 PM, Chris Canal <dhtmlgod@...> wrote:<pythonandchips@...>wrote:
> >
> >> Try this:
> >>
> >> for type in AllTypesBased of IController("Practicum.Web"):
> >> component type.FullName, type:
> >> lifestyle Transient
> >>
> >>
> >> On Tue, Oct 21, 2008 at 2:00 PM, Colin Gemmell> >> --
> >>
> >>> 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
> >>
> >
> >
> >
> > --
> > "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
> >
>
>
>
> --
> "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
>
--
"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