Getting Started with Scrutor for Dependency Injection in .NET Core

Scrutor: Enhancing Dependency Injection in .NET Core Scrutor is a lightweight library for .NET Core that enhances dependency injection (DI) by enabling automated assembly scanning and registration of services. With Scrutor, you can reduce manual configuration by automatically discovering and registering services based on conventions or attributes. How It Works Scrutor builds on top of .NET Core’s built-in Dependency Injection (DI) framework. It simplifies service registration by: Scanning Assemblies: It scans through your project’s assemblies for classes or interfaces that match certain patterns or conventions. Auto-Registering Services: It automatically registers discovered classes with the DI container, specifying their lifetimes (e.g., Transient, Scoped, or Singleton). Applying Filters: You can use predicates to include or exclude specific types during registration. How to Set It Up 1. Install Scrutor Add the NuGet package to your project: ...

March 15, 2025 · 2 min · Taner