Search code examples
aspnetboilerplate

DomainService not registered in AppService


I am trying to incorporate DomainService into my application, and tried to do it like the code below shows. Here is the sample code for the manager:

namespace FlexSped.DefaultColors
{
    public class DefaultColorManager : FlexSpedDomainServiceBase, IDefaultColorsManager
    {
        private readonly IRepository<DefaultColor> _defaultColorRepository;

        public DefaultColorManager(IRepository<DefaultColor> defColorRep)
        {
            _defaultColorRepository = defColorRep;
        }

        public async Task Create(DefaultColor input)
        {
            await _defaultColorRepository.InsertAsync(input);
        }

        public Task Update(int id)
        {
            throw new NotImplementedException();
        }
    }
}

And this is the application service:

namespace FlexSped.DefaultColors
{
    [AbpAuthorize(AppPermissions.Pages_Administration_DefaultColors)]
    public class DefaultColorsAppService : FlexSpedAppServiceBase, IDefaultColorsAppService
    {
        private readonly IDefaultColorsManager _defaultColorManager;
        private readonly IRepository<DefaultColor> _defaultColorRepository;
        //private readonly IIocResolver _iocResolver;

        public DefaultColorsAppService(IRepository<DefaultColor> defaultColorRepository, IDefaultColorsManager defColManager)
        {
            _defaultColorRepository = defaultColorRepository;
            _defaultColorManager = defColManager;
            //_iocResolver = iocResolver;
        }

        public async Task CreateOrEdit(CreateOrEditDefaultColorDto input)
        {
            if (input.Id == null)
            {
                await Create(input);
            }
            else
            {
                await Update(input);
            }
        }

        [AbpAuthorize(AppPermissions.Pages_Administration_DefaultColors_Create)]
        private async Task Create(CreateOrEditDefaultColorDto input)
        {
            DefaultColor dt = ObjectMapper.Map<DefaultColor>(input);
            await _defaultColorManager.Create(dt);
        }
    }
}

All this produces this error:

'FlexSped.DefaultColors.DefaultColorsAppService' is waiting for the following dependencies:
- Service 'FlexSped.DefaultColors.IDefaultColorsManager' which was not registered.

Not sure what the problem is.I was following convention here.


Solution

  • ABPboiler is registering the services dependencies by name so your should match the implementation with definition. In your case:

    IDefaultColors.IDefaultColorsManager should be IDefaultColors.IDefaultColorManager or vice versa DefaultColorManager should be DefaultColorsManager.