Base solution for your next web application
Open Closed

Register app service dependencies #1973


User avatar
0
roxybox created

I have created an app service but having difficulties with its dependencies.

Can't create component 'Roxybox.TrainingManager.Course.CourseAppService' as it has dependencies to be satisfied.

'Roxybox.TrainingManager.Course.CourseAppService' is waiting for the following dependencies:
- Service 'Roxybox.TrainingManager.Courses.Managers.ICourseManager' which was not registered.

The CourseManager appears to be the issue but not sure how to resolve it.

public class CourseAppService : TrainingManagerAppServiceBase, ICourseAppService
    {
        private readonly CourseManager _courseManager;

        public CourseAppService(
           CourseManager courseManager)
        {
            _courseManager = courseManager;
        }
public abstract class CourseManager :  IDomainService, ITransientDependency
    {

        public ILocalizationManager LocalizationManager { get; set; }
        protected IRepository<Course> CourseRepository { get; set; }

        protected CourseManager(
           IRepository<Course> courseRepository)
        {
            CourseRepository = courseRepository;
            LocalizationManager = NullLocalizationManager.Instance;
        }

5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    If you are using IDomainService, you dont have to use ITransientDependency because IDomainService already derives from it.

    Your CourseManager class must derive from DomainService class not IDomainService interface. For a correct implementation please check Domain Service documentation here <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Domain-Services">http://aspnetboilerplate.com/Pages/Docu ... n-Services</a>

  • User Avatar
    0
    roxybox created

    I have updated the CourseManager class based on the documentation and still get the error.

    public abstract class CourseManager :  DomainService, ICourseManager
        {
    
            public ILocalizationManager LocalizationManager { get; set; }
             protected IRepository<Course> CourseRepository { get; set; }
    
            protected CourseManager(
               IRepository<Course> courseRepository)
            {
                CourseRepository = courseRepository;
                LocalizationManager = NullLocalizationManager.Instance;
            }
    }
    
    public interface ICourseManager : IDomainService
        {
    }
    
  • User Avatar
    0
    andmattia created

    Has you check if is a possibile loop of injection?

    Check in browser console the full stack of exception.

  • User Avatar
    0
    roxybox created

    Thanks for the help andmattia. I found that the issue was down to me missing the fact that the Entity was not in the DbContext.

    After adding it everything started to work.

  • User Avatar
    0
    andmattia created

    your welcome!