Search the web
Sign In
New User? Sign Up
glasgow_altdotnet_usersgroup · Glasogw ALT,NET Users Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Binsor with Asp.Net MVC (beta) problem   Message List  
Reply | Forward Message #736 of 763 |
Re: [glasgow_altdotnet_usersgroup] Binsor with Asp.Net MVC (beta) problem

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:
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 <pythonandchips@...> wrote:

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


Tue Oct 21, 2008 1:14 pm

cr_canal
Offline Offline
Send Email Send Email

Forward
Message #736 of 763 |
Expand Messages Author Sort by Date

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...
Colin Gemmell
pythonandchips2
Offline Send Email
Oct 21, 2008
1:00 pm

Try this: for type in AllTypesBased of IController("Practicum.Web"): component type.FullName, type: lifestyle Transient ... -- "Any fool can write code that a...
Chris Canal
cr_canal
Offline Send Email
Oct 21, 2008
1:10 pm

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...
Chris Canal
cr_canal
Offline Send Email
Oct 21, 2008
1:13 pm

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...
Chris Canal
cr_canal
Offline Send Email
Oct 21, 2008
1:14 pm

Cheers Chris that sorted the problem (just as my boss came in perfect timing). Buy you a pint for that. Colin G ... Transient. The ... your ... attribute. ......
Colin Gemmell
pythonandchips2
Offline Send Email
Oct 21, 2008
1:22 pm

No problem, that will also work with your IService component registration, really tidies things up ... -- "Any fool can write code that a computer can...
Chris Canal
cr_canal
Offline Send Email
Oct 21, 2008
1:36 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help