The standard approach of integrating NInject DI with asp.net MVC doesn’t work for Web Api, due to the updates made to the IDependencyResolver interface. In order to make it work, need to create a couple of more interfaces that need to be implemented to help identify the dependencies, as provided below:
3,522 total views, no views today
NInject as a DI framework helps to deal with the common scenario of avoiding creation of concrete objects by providing the basic infrastructure to inject the required objects (using Constructor Injection technique).
Use of Composition Root Pattern: Composition Root is a pattern where the “object graph” definitions are handled in a centralized area. For instance in the case of an ASP.NET MVC (that uses NInject.MVC3) application, the RegisterServices(Ikernel kernel) is considered as the entry point for the application where all dependencies are defined by binding the respective interfaces to the concrete objects (using the Bind API).
Hence by way of maintaining the construction of objects in a single location, the core components will live independent of any dependencies and the DI framework will inject the required interfaces, on-demand.
926 total views, no views today
This post is in continuation to the earlier post on NInject and assumes that the reader has knowledge about NInject and DI concepts. For those, who stumbled upon this link accidentally, read my previous blog about using NInject with ASP.NET MVC4 to get a better idea about NInject.
NInject 3.0 offers a fluent syntax that helps to bind multiple interfaces with a concrete implementation.
3,023 total views, no views today
Dependency Injection – an Introduction
I have always been a big fan of using DI and NInject has been my favorite Dependency Injection tool because of the ease and flexibility it offers for integrating it with any project/solution. (Note: Other DI tools that are worth considering for .net applications are Structure Map, Castle Windsor and Unity). However, this blog is aimed at helping novice users to configure NInject with ASP.NET MVC4 and get started with using DI to achieve Separation Of Concerns (SOC).
7,728 total views, no views today
Today when I was doing some research with “NInject” on an empty ASP.NET MVC application, I got the following error.
Could not load file or assembly ‘Ninject, Version=126.96.36.199, Culture=neutral, PublicKeyToken=c7192dc5380945e7’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
6,578 total views, 8 views today