❔ Why I am having issues to register my services.
The error I get is the following
How i register my services
Then i implement that into the program.cs where my builder resides
Does anyone have any idea why this is not working?
If i remove my latest service it works fluently.
I suspect my httpclient request
System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: StatsByAlfaLaval.Application.Services.TextService.ITextService Lifetime: Scoped ImplementationType: StatsByAlfaLaval.Application.Services.TextService.TextService': Unable to resolve service for type 'System.Net.Http.HttpClient' while attempting to activate 'StatsByAlfaLaval.Application.Services.TextService.TextService'System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: StatsByAlfaLaval.Application.Services.TextService.ITextService Lifetime: Scoped ImplementationType: StatsByAlfaLaval.Application.Services.TextService.TextService': Unable to resolve service for type 'System.Net.Http.HttpClient' while attempting to activate 'StatsByAlfaLaval.Application.Services.TextService.TextService'How i register my services
public static IServiceCollection AddApplication(this IServiceCollection services)
{
services.AddScoped<IAuthenticationService, AuthenticationService>();
services.AddScoped<ITextService, TextService>();
return services;
}public static IServiceCollection AddApplication(this IServiceCollection services)
{
services.AddScoped<IAuthenticationService, AuthenticationService>();
services.AddScoped<ITextService, TextService>();
return services;
}Then i implement that into the program.cs where my builder resides
var builder = WebApplication.CreateBuilder(args);
{
builder.Services
.AddApplication()
.AddInfrastructure();
builder.Services.AddControllers();
}var builder = WebApplication.CreateBuilder(args);
{
builder.Services
.AddApplication()
.AddInfrastructure();
builder.Services.AddControllers();
}Does anyone have any idea why this is not working?
If i remove my latest service it works fluently.
I suspect my httpclient request
public class TextService : ITextService
{
private readonly HttpClient _httpClient;
public TextService(HttpClient httpClient)
{
_httpClient = httpClient;
}public class TextService : ITextService
{
private readonly HttpClient _httpClient;
public TextService(HttpClient httpClient)
{
_httpClient = httpClient;
}