Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

1 vote
2 answers
29 views

.Net 6 worker service EF 6 - Repository DI cannot consume scoped service

I have below folder structure in the .Net 6 worker service with EF 6, Solution file(.sln) | |_ Data(.csproj) | |_ Models | | |_ DatadbContext.cs | | | |_ Repository | |_ DbRepository.cs |...
useruser00's user avatar
1 vote
1 answer
46 views

How Can I Register and Search Through an Arbitrary Number of Classes Using Dependency Injection?

I'm trying to solve an architecture problem involving a gigantic legacy file with several massive switch statements that need to be broken up into discrete classes. I want to solve this by having a ...
Sabelyn's user avatar
  • 13
1 vote
2 answers
105 views

ASP.NET Core 6 Web API base project with multiple API projects

I have a project called backend-sandbox. I want this project to be the startup project of my solution. Once I run this project, it should run all the other projects dependent on it. Other projects can ...
shuja ali's user avatar
1 vote
2 answers
63 views

How is HttpClient injected into a ctor?

I found this ctor: public class MobileOtpService : IMobileOptService { private readonly HttpClient _client; public MobileOtpService(HttpClient client) // How is this injected? { ...
David Klempfner's user avatar
0 votes
0 answers
89 views

Issue with service method call in .NET Background Service , Issue with Scope

I'm facing a weird issue not sure, it's related to scope or async-await. Basically, I've a Background service (singleton), which is registered as: services.AddHostedService<JobBackgroundService>(...
anoop's user avatar
  • 3,812
1 vote
1 answer
46 views

Background Service stops working after sc.exe start

I'm writing code for background service which is designed to collect data by OPC UA protocol. Service worked as intended, before I desided to refactor in order to conform to modern patterns (DI). ...
Anthony Voronkov's user avatar
2 votes
2 answers
137 views

DbContext - passing custom configuration option

I have .NET Core 6 web application with Entity Framework. My DbContext is something like: public class MyDbContext : DbContext { public MyDbContextDbContext(DbContextOptions<MyDbContext> ...
IT Man's user avatar
  • 1,026
0 votes
2 answers
344 views

How to access ILogger in all classes in Azure Function running on .NET Core 6 isolated

I'm converting a web job to an Azure Function. I created an Azure Function with .NET 6 isolated. I'm unable to access the ILogger from class constructor, getting this error: System....
prasanthi's user avatar
  • 596
1 vote
0 answers
83 views

Microsoft.Extensions.DependencyInjection causing bad memory leak

I am new to .NET core and DI. The following is a class I wrote in a .Net 6.0 server app to use Microsoft.Extensions.DependencyInjection. It is causing serious memory leaks at the magnitude of +0.5 to ...
AussieDude's user avatar
0 votes
1 answer
208 views

InvalidOperationException: Service Not Registered in ASP.NET Core Worker Service

I'm working on an ASP.NET Core application with a BackgroundService where I'm facing an issue with dependency injection. I've set up a generic repository pattern and have registered my services in ...
Nico Florez's user avatar
0 votes
0 answers
94 views

How to register generic services with an interface using reflection

I have multiple services with this pattern, each repository class is using generics for the context and is implementing an interface also with generics: public partial interface IUserRepository<...
Bruno's user avatar
  • 4,615
1 vote
2 answers
304 views

Injecting userid in DbContext for multi-tenant application

I am building a multi-tenant application with .net identity. I want each user when they log in to view their own data. I have a user resolver service where i inject httpContextAccessor to try to ...
athagiorgos's user avatar
0 votes
1 answer
176 views

.NET 6 and Quartz.net how to use Dependency Injection for dbcontext?

I am using Quartz.net version 3.7 and need to inject DbContext in the constructor. How would i do it ? Not able to find a good example using .net6. public abstract class BaseJobMgr : IJob { private ...
gjo's user avatar
  • 33
0 votes
0 answers
67 views

Dependency Injection Operation on the class whose Constructor is fixed

In a chatbot project, I keep the users' activities for the last 10 minutes in a session class and send a closing message to the user who has been passive for 10 minutes. I need to keep all users' ...
Berk KARASU's user avatar
2 votes
1 answer
319 views

Common Language Runtime detected an invalid program in a .NET 6 API?

I am using .net6, Microsoft.NET.Sdk.Web, with MVC and Microsoft.Extensions.DependencyInjection 6.0.0. The exception is caused by Microsoft classes and there is nothing to debug. On the API side, the ...
Swirlas's user avatar
  • 21

15 30 50 per page
1
2 3 4 5
9