Tony Mishler edited this page May 5, 2018 · 7 revisions

Ninject is a lightweight dependency injection framework for .NET applications. It helps you split your application into a collection of loosely-coupled, highly-cohesive pieces, and then glue them back together in a flexible manner. By using Ninject to support your software's architecture, your code will become easier to write, reuse, test, and modify.

Ninject is:

  • Focused. Too many existing dependency injection projects sacrifice usability for features that aren't often necessary. Each time a feature is added to Ninject, its benefit is weighed against the complexity it adds to everyday use. Our goal is to keep the barrier to entry - the baseline level of knowledge required to use Ninject - as low as possible. Ninject has many advanced features, but understanding them is not required to use the basic features.

  • Sleek. Framework bloat is a major concern for some projects, and as such, all of Ninject's core functionality is in a single assembly with no dependencies outside the .NET Base Class Library (there's also a build for the Client Profile). This single assembly's footprint is approximately 100KB when compiled for release.

  • Fast. Instead of relying on reflection for invocation, Ninject takes advantage of lightweight code generation in the CLR. This can result in a dramatic (8-50x) improvement in performance in many situations.

  • Precise. Ninject helps developers get things right the first time around. Rather than relying on XML mapping files and string identifiers to wire up components, Ninject provides a robust domain-specific language. This means that Ninject takes advantage of the capabilities of the language (like type-safety) and the IDE (like IntelliSense and code completion).

  • Agile. Ninject is designed around a component-based architecture, with customization and evolution in mind. Many facets of the system can be augmented or modified to fit the requirements of each project.

  • Stealthy. Ninject will not invade your code. You can easily isolate the dependency on Ninject to a single assembly in your project.

  • Powerful. Ninject includes many advanced features. For example, Ninject was the first dependency injector to support contextual binding, in which a different concrete implementation of a service may be injected depending on the context in which it is requested. Ninject supports most major facilities offered by competing frameworks (although many such elements live in extensions - plugin modules that layer on facilities on top of the core).

Note: This wiki/site is for the main version of Ninject, which is a ground-up rewrite of Ninject 1. The implementation relies heavily on LINQ, so if you're not targeting the .NET Framework 3.5 or higher (or equivalent Silverlight/Compact/Mono versions), you'll need to use version 1 of Ninject.

Continue reading: Why use Ninject?

If you're very familiar with, or relying on materials targeting v1, you'll want to read changes in Ninject 2.

Ninject v3 was released in early 2012. To learn more read changes in Ninject 3

Some of the documentation has not yet been synced with the v2 rewrite - see the "status overview in the TOC": Please bear with us as the contributors tasked with the work get around to providing detailed and accurate documentation that strikes that critical balance between facts and tutorial. And remember, it's a wiki - if something confuses you or you feel you can clarify something, don't hesitate to edit - the worst that can happen is that it'll be rolled back!

More Resources:

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.