It’s all in the Host Class – Dependency Injection with .NET

It’s all in the Host Class – Dependency Injection with .NET

In the first article of this series, dependency injection is introduced, and I’m showing how a dependency injection container can be created with the Host class. Continue reading It’s all in the Host Class – Dependency Injection with .NET

Disposing Injected Services (or: Using Dependency Injection Scopes)

Disposing Injected Services (or: Using Dependency Injection Scopes)

The DI container Microsoft.Extensions.DependencyInjection disposes registered services automatically. It’s just the question when the dispose takes place. Automatic dispose of transient and scoped services happen at the end of a scope. With ASP.NET Core applications, scopes are created with every HTTP request – after the request, services are disposed. This article shows creating and using DI scopes with XAML-based applications. Continue reading Disposing Injected Services (or: Using Dependency Injection Scopes)