.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Asp.Net MVC 2 - IoC (Castle Windsor)

Posted By:      Posted Date: October 23, 2010    Points: 0   Category :ASP.Net

I'm trying to set up IoC (Castle Windsor) in my MVC 2 project here, using the section in Pro Asp.net MVC Framework book.

However, I cannot compile after creating a custom controller factory as stated in the book.

This part give me error:

// Constructs the controller instance needed to service each request
protected override IController GetControllerInstance(Type controllerType)
    return (IController) container.Resolve(controllerType);

Telling me that no suitable method have been found to override?

Does someone know if there's a problem with the code in the book or something changed with recent versions of things (wont suprise me..got some books on MVC here rendered completely useless with the evolution of asp.net mvc)

View Complete Post

More Related Resource Links

problem with castle IoC and Pro ASP MVC Framework tutorial


At first i was getting a null exception with the following statement: return (IController) container.Resolve(controllerType);

I think it was because i was using deprecated code:

            foreach (Type t in controllerTypes)
                container.AddComponentWithLifestyle(t.FullName, t, LifestyleType.Transient);

I changed that to :

            foreach (Type t in controllerTypes)

Now i get this error and can't figure out what it means.  I'm also not sure if i should use component.For<Type>..  

ComponentNotFoundException:  No component for supporting the service WebUI.Controllers.ProductsController was found

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend