14

I have heard that in the next version of ASP.NET (ASP.NET vnext) there will be dependency injection built into the framework. Does anyone know more about this? Will it be unity or a new framework? Where can I find more information about this?

M4N
  • 94,805
  • 45
  • 217
  • 260
Alexander
  • 420
  • 1
  • 5
  • 17
  • 1
    Dependency injection is built into the framework. Use your preferred IoC container to register dependencies. reference : http://www.asp.net/vnext/overview/aspnet-vnext/overview – Zaki May 22 '14 at 12:33

4 Answers4

10

ASP.NET vNext will have built-in support for dependency injection. It is very basic support that currently supports only constructor injection.

The source repo for ASP.NET vNext's dependency injection logic contains sample implementations of how to wire up several community-built dependency injection systems, including Autofac, Ninject, StructureMap, Unity, and Castle Windsor. However, those are just samples and are not all complete or fully functional.

The idea is that for basic scenarios a developer can use the built-in DI, whereas people with more advanced requirements or if they already have a "favorite" DI system can plug that in instead and get richer features.

Eilon
  • 25,582
  • 3
  • 84
  • 102
  • Se we finally get built-in support for the Dependency Injection pattern as well as the Service Locator pattern. Cool. – Christopher Stevenson Jun 17 '14 at 05:57
  • See also this discussion https://github.com/simpleinjector/SimpleInjector/issues/41#issuecomment-100470660 pointing out that it might not be the best idea to replace the built-in container, but rather to use a custom container side-by-side. – Martin Klinke Feb 16 '16 at 08:21
3

It will contain common abstractions for Autofac, Ninject, StructureMap, Unity, Windsor as seen here Dependency Injection github If you see in the Project.Json it has dependencies on these specific frameworks.

taher chhabrawala
  • 4,110
  • 4
  • 35
  • 51
  • Apparently, this will not be the case, at least not in the sense that ASP.NET vNext will _contain_ those abstractions. It depends on the container providers, see also http://stackoverflow.com/questions/32788637/continued-ninject-support-in-asp-net-mvc-6?lq=1 – Martin Klinke Feb 16 '16 at 08:20
2

Here is instruction how to use Autofac with ASP.NET 5

druss
  • 1,820
  • 19
  • 18
1

This blog explains the details on hov to wire up your own container: http://blogs.msdn.com/b/webdev/archive/2014/06/17/dependency-injection-in-asp-net-vnext.aspx

Jens
  • 2,327
  • 25
  • 34