Answer the question
In order to leave comments, you need to log in
How to inject an ASP.NET Web Api service?
How can I inject an interface for a service?
Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: X.Services.Interfaces.ServiceInterfaces.IWishListItemService Lifetime: Scoped ImplementationType: X.Infrastructure.Business.Services.WishListItemService': Unable to resolve service for type 'X.Domain.Interfaces.EFInterfaces.IWishListItemRepository' while attempting to activate 'X.Infrastructure.Business.Services.WishListItemService'.) (Error while validating the service descriptor 'ServiceType: X.Services.Interfaces.ServiceInterfaces.IWishListItemService Lifetime: Scoped ImplementationType: X.Infrastructure.Business.Services.WishListItemService': Unable to resolve service for type 'X.Domain.Interfaces.EFInterfaces.IWishListItemRepository' while attempting to activate 'X.Infrastructure.Business.Services.WishListItemService'.)
public class WishListItemService : IWishListItemService
{
private readonly IMapper _mapper;
private readonly IUnitOfWork _unitOfWork;
private readonly IWishListItemRepository _wishListItemRepository;
private readonly IProductDetailsRepository _productDetailsRepository;
public WishListItemService(IMapper mapper, IUnitOfWork unitOfWork,
IWishListItemRepository wishListItemService, IProductDetailsRepository productDetailsRepository)
{
_wishListItemRepository = wishListItemService;
_productDetailsRepository = productDetailsRepository;
_unitOfWork = unitOfWork;
_mapper = mapper;
}
public class WishListItemController : ControllerBase
{
private readonly IMapper _mapper;
private readonly IWishListItemService _wishListItemService;
public WishListItemController(IWishListItemService wishListItemService, IMapper mapper)
{
_mapper = mapper;
_wishListItemService = wishListItemService;
}
Answer the question
In order to leave comments, you need to log in
Register like WishListItemService.
Most likely somewhere in Startup.ConfigureServices
services.AddScoped<IWishListItemRepository, WishListItemRepository>()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question