'A suitable constructor could not be located error

I am getting an error on this piece of code and don't have a clue what to do. Can anyone tell me what the problem could be and how to resolve it.

Error:

An unhandled exception occurred while processing the request. InvalidOperationException: A suitable constructor for type 'Lic.Controllers.EchipamentController' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.

FindApplicableConstructor Stack Query Cookies Headers InvalidOperationException: A suitable constructor for type 'Lic.Controllers.EchipamentController' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.

namespace Licenta.Controllers
{
    public class EchipamentController:Controller
    {
        private readonly ICategoryRepository _categoryRepository;
        private readonly IEchipamentRepository _echipamentRepository;


        EchipamentController(ICategoryRepository categoryRepository, IEchipamentRepository echipamentRepository)
        {
            _categoryRepository = categoryRepository;
            _echipamentRepository = echipamentRepository;           
        }

        public ViewResult List()
        {
            var echipamente = _echipamentRepository.Echipamente;
            return View(echipamente);
        }
    }
}

I don t know what to do about that error.



Solution 1:[1]

add public to this part of your code:

public EchipamentController(ICategoryRepository categoryRepository, IEchipamentRepository echipamentRepository)
    {
        _categoryRepository = categoryRepository;
        _echipamentRepository = echipamentRepository;           
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 iluha