问题
I am new to the ioc containers and confused how to integrate a container to mvc3...
There is a sample that uses ControllerFactory... https://github.com/kkozmic/ToBeSeen/blob/master/src/ToBeSeen/Plumbing/WindsorControllerFactory.cs
There is a blog post that says "The MVC 3.0 IDependencyResolver interface is broken. Don’t use it with Windsor." http://mikehadlow.blogspot.com/2011/02/mvc-30-idependencyresolver-interface-is.html
and from this link I think I also need to implement IControllerActivator... Castle Windsor Dependency Resolver for MVC 3
In pluralsight's mvc3 dependency resolution videos scot allen says using activators is necessary if your ioc container is not enough for it... this also makes me think about using windsor with DependencyResolver.
回答1:
I'm using ControllerFactory since a while with no problem at all. There's a very usefull tutorial on windsor wiki
In case you need your action been resolved by an IoC I suggest you http://weblogs.asp.net/psteele/archive/2009/11/04/using-windsor-to-inject-dependencies-into-asp-net-mvc-actionfilters.aspx
Due to missing release operation, IDependencyResolver is not enough: stay away from it.
来源:https://stackoverflow.com/questions/8077104/if-you-are-starting-a-new-mvc3-project-which-adaption-will-you-choose-dependency