title: Ninject Web Api "Make sure that the controller has a parameterless public constructor."
body: <p>I've been using ninject for almost 2 years but now when using it my ASP.NET MVC/WebAPI project i get this message and the previous threads on stackoverflow with various suggestions hasn't solved my problem.
  I have the follow nuget packages:
  Ninject MVC3
  Ninject Integration for WebApi 2.</p>
  
  <p>I've tried solving the problem for longer that I'd like too and would really appreciate any help and suggestions that i could get!
  (Id gladly put the solution on Github if someone want to take a closer look)</p>
  
  <p>Here are the classes that I use:</p>
  
  <pre><code>public class CmsContext : DbContext
  {
  
      public CmsContext()
          : base("CMS_POC")
      { }
  
      public DbSet&lt;Activity&gt; Activities { get; set; }
      public DbSet&lt;CMS.Entities.System&gt; Systems { get; set; }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          modelBuilder.Conventions.Remove&lt;PluralizingTableNameConvention&gt;();
  
      }
  }
  
  public interface IRepository&lt;T&gt; where T : IEntityBase
  {
      IEnumerable&lt;T&gt; GetAll { get; }
      void Add(T entity);
      void Delete(T entity);
      void Update(T entity);
      T GetById(int Id);
  }
  
  public class SystemRepository : IRepository&lt;CMS.Entities.System&gt;
  {
      private CmsContext _systemContext;
  
      public SystemRepository(CmsContext systemContext)
      {
          _systemContext = systemContext;
      }
  
      public IEnumerable&lt;Entities.System&gt; GetAll
      {
          get
          {
              return _systemContext.Systems;
          }
      }
  
      public void Add(Entities.System entity)
      {
          _systemContext.Systems.Add(entity);
          _systemContext.SaveChanges();
      }
  
      public void Delete(Entities.System entity)
      {
          _systemContext.Systems.Remove(entity);
          _systemContext.SaveChanges();
      }
  
      public void Update(Entities.System entity)
      {
          var system = _systemContext.Systems.SingleOrDefault(s =&gt; s.System_Id == entity.System_Id);
  
          system = entity;
          _systemContext.SaveChanges();
      }
  
      public Entities.System GetById(int Id)
      {
          return _systemContext.Systems.SingleOrDefault(s =&gt; s.System_Id == Id);
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public class ActivityRepository : IRepository&lt;Activity&gt;
  {
      private CmsContext _activityContext;
  
      public ActivityRepository(CmsContext activityContext)
      {
          _activityContext = activityContext;
      }
  
  
      public IEnumerable&lt;Activity&gt; GetAll
      {
          get
          {
              return _activityContext.Activities;
          }
      }
  
      public void Add(Activity entity)
      {
  
          _activityContext.Activities.Add(entity);
          _activityContext.SaveChanges();
      }
  
      public void Delete(Activity entity)
      {
          _activityContext.Activities.Remove(entity);
          _activityContext.SaveChanges();
      }
  
      public void Update(Activity entity)
      {
          var activity = _activityContext.Activities.SingleOrDefault(a =&gt; a.Activity_Id == entity.Activity_Id);
  
          activity = entity;
          _activityContext.SaveChanges();
  
      }
  
      public Activity GetById(int Id)
      {
          return _activityContext.Activities.SingleOrDefault(a =&gt; a.Activity_Id == Id);
      }
  
  
   }
  
  public interface IActivityService
      {
          IReadOnlyList&lt;Activity&gt; GetActivities();
          Activity GetSingleActivity(int id);
          Activity CreateActivity(string activityName, DateTime startDate, DateTime endDate, int systemId);
          Activity UpdateActivity(int activityId, string activityName, DateTime startDate, DateTime endDate);
          void DeleteActivity(int activityId);
      }
  
  public interface ISystemService
      {
          IReadOnlyList&lt;CMS.Entities.System&gt; GetSystems();
          CMS.Entities.System GetSingleSystem(int id);
          CMS.Entities.System CreateSystem(string systemName);
          CMS.Entities.System UpdateSystem(int systemId, string systemName);
          void DeleteSystem(int systemId);
      }
  
      public class ActivityService : IActivityService
      {
          private IRepository&lt;Activity&gt; _activityRepository;
          private IRepository&lt;Entities.System&gt; _systemRepository;
  
          public ActivityService(IRepository&lt;Activity&gt; activityRepository, IRepository&lt;Entities.System&gt; systemRepository)
          {
              _activityRepository = activityRepository;
              _systemRepository = systemRepository;
          }
  }
  </code></pre>
  
  <p>This is just a short part of the service class but I want to show how I'm using DI with the services.</p>
  
  <p>And finally there configuration for ninject:</p>
  
  <pre><code>public static class NinjectWebCommon 
  {
      private static readonly Bootstrapper bootstrapper = new Bootstrapper();
  
      /// &lt;summary&gt;
      /// Starts the application
      /// &lt;/summary&gt;
      public static void Start() 
      {
          DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
          DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
          bootstrapper.Initialize(CreateKernel);
      }
  
      /// &lt;summary&gt;
      /// Stops the application.
      /// &lt;/summary&gt;
      public static void Stop()
      {
          bootstrapper.ShutDown();
      }
  
      /// &lt;summary&gt;
      /// Creates the kernel that will manage your application.
      /// &lt;/summary&gt;
      /// &lt;returns&gt;The created kernel.&lt;/returns&gt;
      private static IKernel CreateKernel()
      {
          var kernel = new StandardKernel();
          try
          {
              kernel.Bind&lt;Func&lt;IKernel&gt;&gt;().ToMethod(ctx =&gt; () =&gt; new Bootstrapper().Kernel);
              kernel.Bind&lt;IHttpModule&gt;().To&lt;HttpApplicationInitializationHttpModule&gt;();
  
              RegisterServices(kernel);
              return kernel;
          }
          catch
          {
              kernel.Dispose();
              throw;
          }
      }
  
      /// &lt;summary&gt;
      /// Load your modules or register your services here!
      /// &lt;/summary&gt;
      /// &lt;param name="kernel"&gt;The kernel.&lt;/param&gt;
      private static void RegisterServices(IKernel kernel)
      {
          kernel.Bind&lt;IActivityService&gt;().To&lt;ActivityService&gt;();
          kernel.Bind&lt;ISystemService&gt;().To&lt;SystemService&gt;();
          kernel.Bind&lt;IRepository&lt;Activity&gt;&gt;().To&lt;ActivityRepository&gt;();
          kernel.Bind&lt;IRepository&lt;CMS.Entities.System&gt;&gt;().To&lt;SystemRepository&gt;();
      }        
  }
  </code></pre>
  
  <p>EDIT*
  Forgot my controller</p>
  
  <pre><code>public class ActivitiesController : ApiController
  
  {
      private IActivityService _activityService;
  
      public ActivitiesController(IActivityService activityService)
      {
          _activityService = activityService;
      }
  }
  </code></pre>