Base solution for your next web application
Open Closed

Dependency Injection in MAUI app doesn't resolve #11537


User avatar
0
dmux created

I am trying to get started with the MAUI project so I can build out the mobile interface for my project. I have created a ProxyAppService which inherits from my AppService interface, but the DependencyResolver fails to resolve it in the razor.cs, throwing "No component for supporting the service DMux.WebPortal.Common.IPeopleAppService was found"

I tried putting builder.Services.AddSingleton<IPeopleAppService, ProxyPersonAppService>(); in the MauiProgram.cs but it made no difference.

My interface:

The Interface:

public interface IPeopleAppService : IApplicationService
    {
        Task < PagedResultDto < GetPersonForViewDto > > GetAll(GetAllPeopleInput input);

        Task < GetPersonForViewDto > GetPersonForView(int id);

        Task < GetPersonForEditOutput > GetPersonForEdit(EntityDto input);

        Task CreateOrEdit(CreateOrEditPersonDto input);

        Task Delete(EntityDto input);

        Task < FileDto > GetPeopleToExcel(GetAllPeopleForExcelInput input);

        Task < PagedResultDto < PersonUserLookupTableDto > > GetAllUserForLookupTable(GetAllForLookupTableInput input);
    }


The ProxyAppService:

public class ProxyPersonAppService : ProxyAppServiceBase, IPeopleAppService
    {
        public async Task CreateOrEdit(CreateOrEditPersonDto input)
        {
            await ApiClient.PostAsync(GetEndpoint(nameof(CreateOrEdit)), input);
        }

        public async Task Delete(EntityDto input)
        {
            await ApiClient.DeleteAsync(GetEndpoint(nameof(Delete)), input);
        }

        public async Task < PagedResultDto < GetPersonForViewDto > > GetAll(GetAllPeopleInput input)
        {
            return await ApiClient.GetAsync < PagedResultDto < GetPersonForViewDto > > (GetEndpoint(nameof(GetAll)), input);
        }

        public async Task < PagedResultDto<PersonUserLookupTableDto > >  GetAllUserForLookupTable(GetAllForLookupTableInput input)
        {
            return await ApiClient.GetAsync < PagedResultDto < PersonUserLookupTableDto > > (GetEndpoint(nameof(GetAllUserForLookupTable)), input);
        }

        public async Task < FileDto > GetPeopleToExcel(GetAllPeopleForExcelInput input)
        {
            return await ApiClient.GetAsync < FileDto > (GetEndpoint(nameof(GetPeopleToExcel)), input);
        }

        public async Task < GetPersonForEditOutput > GetPersonForEdit(EntityDto input)
        {
            return await ApiClient.GetAsync < GetPersonForEditOutput > (GetEndpoint(nameof(GetPersonForEdit)), input);
        }

        public async Task < GetPersonForViewDto > GetPersonForView(int id)
        {
            return await ApiClient.GetAsync < GetPersonForViewDto > (GetEndpoint(nameof(GetPersonForViewDto)), id);
        }
    }

I have tried starting from a brand new version 12 template. The only things I have added are the People data table (using PowerTools), and the configs required to get the project up and running. I'm happy to pack the whole project up and post it if required.


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

    Hi,

    Could you rename ProxyPersonAppService to ProxyPeopleAppService and see if it works ?

  • User Avatar
    0
    dmux created

    Absolute legend. Great catch, thanks. That worked.

    I regretted using People as the plural, and I'd forgotten how many things work on matching the names.

    Anyway, that's got me past the big roadblock. Cheers.