Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are all this Ninject packages in nuget for integrating with WEB API?

I am building an application using Ninject (MVC5 + WEBAPI). And having some issues figuring out which ones of the many answers explain the most up to date solution to integrate Ninject and WebApi. So I have the following packages installed:

  • Ninject
  • Ninject Integration for WebApi2
  • Ninject.MVC5
  • Ninject.Web.Common
  • Ninject.Web.Common.WebHost

Some people suggest that my initial problem (Ninject is not resolving the API controllers instantiation) should be resolved by either:

  • Installing another package (Ninject.Web.WebApi-RC, Ninject.WebAPI, etc.)
  • Creating my own dependency resolver
  • Installing Ninject Owin host
  • Mix any of the above and hope it finally works.

So it comes down to, what are all this packages? Also, do I need to use Owin hosting? I got an 'Unable to find package Ninject.Web.WebApi' message from nuget console so I assume this one doesn't exist anymore?.

Thanks.

like image 205
Ernesto Avatar asked Jun 30 '14 14:06

Ernesto


1 Answers

There are several packages you need to get Ninject working with Web API 2:

  • Ninject (base library)
  • Ninject.Web.Common
  • Ninject.Web.Common.WebHost
  • Ninject.Web.WebApi.WebHost ("Ninject Web Host for WebApi 2")
  • Ninject.Web.WebApi ("Ninject Integration for WebApi 2")

After you install all of those, you'll find a pre-built NinjectWebCommon class in your App_Start folder. Just add you bindings to the RegisterServices() method.

like image 117
Pharylon Avatar answered Oct 31 '22 16:10

Pharylon