Ninject error in WebAPI 2.1 - Make sure that the controller has a parameterless public constructor

Did you modify your OWIN Startup class to call app.UseNinjectWebApi and app.UseNinjectMiddleware rather than calling app.UseWebApi?

Startup.cs in the Ninject Web API samples does this...


In my case, the reason was resolver could not find a mapping. That is suppose say HomeController has a dependency on IDumb, the resolver could not find a concrete implementation of Dumb with implements IDumb. In other words the error message

**No parameterless constructor defined for this object
An error occurred when trying to create a controller of type 'ToDoListT1.WebApp.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor**

is completely misleading. In my case I just resolved by adding a reference to the project of the class Dumb. It should have been something like "No mapping for IDumb could be found.". I am not sure the problem is with NInject or MS. What ever it took me hours to find this out.


My solution is add "public" keyword to constructor.