Sitemap
.Net Programming

Explore the .Net with the latest in C# from basic to advanced, including .Net versions 9, 8, 6, 5, Core 3.1, .Net Framework, ASP.NET Core, MVC, design patterns, OOPS, and SOLID principles. Get top tutorials, best practices, and hands-on code examples on GitHub.

Follow publication

Member-only story

How To Detect Unregistered Dependencies on Startup in .Net Core

.Net Labs
3 min readOct 18, 2024

I am very much sure that this article will be very interesting.

Suppose we have big application and have 100 of controllers, we keep adding code and injecting services in controllers. At some moment we forget to Register service at Startup.cs

Non members can access from here

Consider code below

 public class DiTestController: ControllerBase
{
private readonly SQlDBService _sqlDataService;
public DiTestController(SQlDBService sqlDbService)
{
_logger = logger;
_sqlDataService = sqlDbService;
}
}

we injected SQlDBService and forget to register SQlDBService at program.cs

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers() .AddControllersAsServices(); ;
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

.Net Programming

Published in .Net Programming

Explore the .Net with the latest in C# from basic to advanced, including .Net versions 9, 8, 6, 5, Core 3.1, .Net Framework, ASP.NET Core, MVC, design patterns, OOPS, and SOLID principles. Get top tutorials, best practices, and hands-on code examples on GitHub.

.Net Labs

Written by .Net Labs

I am Tech evangelist who is expert in Crafting Coders. #coding #programming

No responses yet

Write a response

Recommended from Medium