title: Parameterless constructor error with Ninject bindings in .NET Web Api 2.1
body: <p>Working currently on writing an API site (.NET Web Api 2.1)</p>
  
  <p>For our prior API sites we had used the Ninject.MVC3 package and wired up a dependency resolver and scope manually and plugged in our logic into NinjectWebCommon as per the recommendation.</p>
  
  <p>This was causing heartburn int our new project with the parameterless constructor error. In the past, this was a dead give away that we were not wiring up the dependency resolver in Web Api properly. Only this time, we were. It was there.</p>
  
  <pre><code>var resolver = new NinjectDependencyResolver(kernel);
  GlobalConfiguration.Configuration.DependencyResolver = resolver;
  </code></pre>
  
  <p>So I was a tad lost. In the last week, I saw that Ninject was updated, the WebAPI nuget package was revived so I decided to try and implement.</p>
  
  <p>I installed the NuGet package Ninject.Web.WebApi (version 3.2). This didn't seem to include a NinectWebCommon.cs file to apply bindings. It only added the necessary assemblies. Doing some digging I stumbled across this implementation.</p>
  
  <p><a href="https://gist.github.com/odytrice/5842010">https://gist.github.com/odytrice/5842010</a></p>
  
  <p>(I was unclear if the Nuget package was doing this for me and this is all redundant code. If so, great, I just need an understanding of how to add our bindings with the nuget package now.)</p>
  
  <p>I implemented this line for line except where loading the modules, I loaded our three individual modules as a test.</p>
  
  <pre><code>public static INinjectModule[] Modules
  {
      //get { return new INinjectModule[] { new MainModule() }; }
      get { return new INinjectModule[] { new GlobalModule(), new InventoryModule(), new StoreModule() }; }
      }
  </code></pre>
  
  <p>I've verified that the dependency resolver is being set with this new code.</p>
  
  <pre><code>_resolver = new NinjectHttpResolver(modules);
  GlobalConfiguration.Configuration.DependencyResolver = _resolver;
  </code></pre>
  
  <p>But still, the problem persists.</p>
  
  <p>ExceptionMessage:</p>
  
  <pre><code>An error occurred when trying to create a controller of type 'StoreSearchController'.
  Make sure that the controller has a parameterless public constructor.
  </code></pre>
  
  <p>StackTrace:</p>
  
  <pre><code>at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) 
  at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request) 
  at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) 
  at System.Web.Http.Dispatcher.HttpControllerDispatcher.&lt;SendAsync&gt;d__0.MoveNext()
  </code></pre>
  
  <p>Inner Exception Exception Type: System.ArgumentException</p>
  
  <p>StackTrace:</p>
  
  <pre><code>at System.Linq.Expressions.Expression.New(Type type) 
  at System.Web.Http.Internal.TypeActivator.Create[TBase](Type instanceType) 
  at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1&amp; activator) 
  at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
  </code></pre>
  
  <p>I'm at a loss. I've seen lots of posts around having to set a MVC dependency resolver as well, but didn't think that was related as in this case we have no MVC controllers outside of the home controller which does not use Ninject.</p>
  
  <p>One other tidbits that may or may not matter. We are using attribute routing.</p>
  
  <p>Any help is appreciated.</p>