I have added the NuGet package: Ninject.Web.WebApi.WebHost to my ASP.NET Web API project, however, once I add all of my DI bindings, I get the following error message:
Error activating HttpConfiguration More than one matching bindings are available. Matching bindings:
1) binding from HttpConfiguration to method
2) binding from HttpConfiguration to method
Activation path: 1) Request for HttpConfiguration
Suggestions: 1) Ensure that you have defined a binding for HttpConfiguration only once.
These are the NuGet packages that are added along with Ninject.Web.WebAPI.WebHost:
- Ninject v. 3.2.2
- Ninject.Web.Common v. 3.2.3
- Ninject.Web.Common.WebHost v. 3.2.3
- Ninject.Web.WebApi v. 3.2.4
- Ninject.Web.WebApi.WebHost v. 3.2.4
I have no idea how to resolve this since I was able to get this to work on previous projects, but this project does not seem to be working for whatever reason.
I also encounter this error message frequently with all of these versions of the assemblies:
Make sure that the controller has a parameterless public constructor
Sometimes I am able to build the project correctly with older versions of the Ninject assemblies, but I frequently get the error message:
Sequence contains no elements.
The only way I have discovered to resolve this error is to delete the bin directory and re-build, but I don't understand why I constantly have to delete the bin directory to get Ninject to work properly each time.
Please advise as to how to get Ninject to work properly with Web API v.2.2