Did something change in MVC 3? I have tried all the examples on the Internet for setting up Unity as my IoC Container, but I keep getting an error saying that Unity cannot resolve my UserController. Here is my constructor on my UserController:
public UserController(IUserService userService)
{
_userService = userService;
}
I have the IUserService registered, that is not the problem. I keep getting errors, no matter what example I try. Does anyone have a good tutorial, or code, that works with Asp.Net MVC 3?
For reference, I have tried this, this, this, and this ... and tons of others.
Error:
The type UserController cannot be constructed. You must configure the container to supply this value.
ErrorLine:
controller = MvcUnityContainer.Container.Resolve(controllerType) as IController;
Configuration:
MvcUnityContainer.Container = new UnityContainer().RegisterType<IUserService, UserService>();
ControllerBuilder.Current.SetControllerFactory(typeof(UnityControllerFactory));