ASP.Net MVC 6: Recursive Dependency Injection
<p>Still exploring the new ASP.NET MVC5, now with build in DI!</p>

<p>No Problem so far, I can just inject my Handlers (I don't like the Term Service, since this defines to me a Platform-Neutral Interface):</p>

<pre><code>    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddApplicationInsightsTelemetry(Configuration);

        services.Configure&lt;Model.Meta.AppSettings&gt;(Configuration.GetSection("AppSettings"));

        services.AddSingleton(typeof(Logic.UserEndPointConfigurationHandler));
        services.AddSingleton(typeof(Logic.NetworkHandler));

        services.AddMvc();
    }
</code></pre>

<p>Works fine, also the strongly typed Configuration-Object "AppSettings" works perfectly fine.</p>

<p>Also the Injection in the Controllers works as well.
But now my collaps: I seperated my DataAccess from the Handlers, and obviously I'd like to inject them as well:</p>

<pre><code>public class UserEndPointConfigurationHandler
{
    private readonly DataAccess.UserEndPointAccess _access;

    public UserEndPointConfigurationHandler(DataAccess.UserEndPointAccess access)
    {
        _access = access;
    }
</code></pre>

<p>But bam, UserEndPointAccess can't be resolved. So it seems like even I directly request to DI an Class with a Parameterless-Constructor, I need to register that. For this case, sure I should Interface and register them, but what does that mean for internal helper classes I also inject? </p>

<p>According to the Docs: <a href="http://docs.asp.net/en/latest/fundamentals/dependency-injection.html#recommendations" rel="nofollow">http://docs.asp.net/en/latest/fundamentals/dependency-injection.html#recommendations</a> and also the examples I found, all people in the world only seem to communicate between Controllers and some Repositories. No Business-Layer and no Classes on different Abstraction-Levels in Assemblies.</p>

<p>Is the Microsoft DI approach something totally differnt than the good ol' Unity one, where I can really decouple as fine granular as I'd like to?</p>

<p>Thanks in advance.</p>

<p>Matthias</p>

<p>Edit @Nightowl: I add my answer here, since it's a bit longer.
First of all, Unity does automatically create Instances, if I request a conecrete Type. This allows me to inject Types I register and Types, like Helper classes etc. I don't need to. This combination allows me to use DI everywhere.</p>

<p>Also in your Example I'd need to know the DataAcces in the WebGui, which is quite thight coupled. Well, I know there are solutions for this via Reflection, but I hoped Microsoft did something in this Topic, but probably that'd mean to big of a change.</p>

<p>Also allows Unity to store Instances or Instructions how to create them, another huge feature, which is missing at the moment.</p>

<p>Probably I'm just to spoiled, what refined DI-Libraries do, probably they also do to much, but at the moment the Microsoft-Implementation is just a huge downgrade according to my Information.</p>