When are .NET Core dependency injected instances disposed? : <p>ASP.NET Core uses extension methods on <code>IServiceCollection</code> to set up dependency injection, then when a type is needed it uses the appropriate method to create a new instance:</p>

<ul>
<li><code>AddTransient&lt;T&gt;</code> - adds a type that is created again each time it's requested.</li>
<li><code>AddScoped&lt;T&gt;</code> - adds a type that is kept for the scope of the request.</li>
<li><code>AddSingleton&lt;T&gt;</code> - adds a type when it's first requested and keeps hold of it.</li>
</ul>

<p>I have types that implement <code>IDisposable</code> and that will cause problems if they aren't disposed - in each of those patterns when is <code>Dispose</code> actually called?</p>

<p>Is there anything I need to add (such as exception handling) to ensure that the instance is always disposed?</p>
