|
|
I'm having trouble using SimpleInjector with MVC4/Web API, I've installed it as per the MVC3 way and in SimpleInjectorInitializer::InitializeContainer() I register my repository, however when I execute a controller that uses this repository I get:
Type 'Core.Controllers.CountryController' does not have a default constructor
Why would this be?
|
|
|
|
It seems that the problem may be down to the controller type, Controller normally implements IController etc, however under the new Web API the ApiController class is defined as:
public abstract class ApiController : IHttpController, IDisposable
Whilst in your code you explicitly check for IController compatibility so the controller is never found :/
|
|
Coordinator
Jun 29, 2012 at 10:05 AM
|
Take a look at this stackoverflow answer. It will answer your question.
|
|