© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
40 replies
hellounlimited

dependency injection in net framework

hi all, i understand that in net core we can add dependency injection like this
IConfiguration Configuration = new ConfigurationBuilder()
  .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
  .AddEnvironmentVariables()
  .AddCommandLine(args)
  .Build();

var builder = WebApplication.CreateBuilder(args);

// Add services to the container. 
builder.Services.AddControllersWithViews(); 
builder.Services.AddHttpClient(); 
builder.Services.AddScoped<Note>();
IConfiguration Configuration = new ConfigurationBuilder()
  .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
  .AddEnvironmentVariables()
  .AddCommandLine(args)
  .Build();

var builder = WebApplication.CreateBuilder(args);

// Add services to the container. 
builder.Services.AddControllersWithViews(); 
builder.Services.AddHttpClient(); 
builder.Services.AddScoped<Note>();


but this way doesnt seem to work in net framework, can anyone help advise how can we do this in net framework?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,828Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

dependency injection net framework
C#CC# / help
4y ago
Dependency Injection not working (.NET 8)
C#CC# / help
3y ago
Dependency injection
C#CC# / help
6mo ago
✅ Dependency injection
C#CC# / help
2y ago