// using Microsoft.Extensions.DependencyInjection; var services = new ServiceCollection(); services.AddAssembly(Assembly.GetExecutingAssembly()); // register services services.AddSingleton();
// using Microsoft.Extensions.DependencyInjection; var services = new ServiceCollection(); services.AddAssembly(typeof(CustomService).Assembly); // register services services.AddScopedThis example adds all types from the assembly containing the CustomService type to the IoC container and then registers a scoped instance of CustomService as IService. The package library for the Container.AddAssembly method is Microsoft.Extensions.DependencyInjection. This library provides a lightweight IoC container for .NET applications and is often used in combination with ASP.NET Core web applications.();