I have just installed the mvc4 rc update and I am trying to build an api application with little luck.
I am using ninject but cant get my controllers to load. I keep
For someone landing here while searching '...does not have a default constructor' looking for an easy way to debug silently failing configurations:
ServiceLocator.Current.GetInstance<[OBJ-TYPE]>()
The offending object will cause an ActivationException with a descriptive Message. You'll have something to go for.
Remember to remove call to ServiceLocator post-fix. Ie. this is not a recommendation to use the service locator anti pattern outside debugging.
I asked Brad Wilson about this and it has changed in MVC4 RC.
GlobalConfiguration.Configuration.ServiceResolver has been moved to GlobalConfiguration.Configuration.DependencyResolver
Use this implementation to create a Ninject DependencyResolver for your Web Api: https://gist.github.com/2417226
In NinjectWebCommon.cs:
// Register Dependencies
RegisterServices(kernel);
// Set Web API Resolver
GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);
just install Ninject.MvcXXX package, where XXX - version of MVC...
I had this error message, too, but it just turned out that one of my interfaces weren't actually implemented by any classes (I forgot to add it to the class declaration).
You can install the NuGet package WebApiContrib.IoC.Ninject and add the following line of code to NinjectWebCommon.cs
GlobalConfiguration.Configuration.DependencyResolver = new NinjectResolver(kernel);