Base solution for your next web application
Open Closed

DependencyResolver does not resolve for interface #12091


User avatar
0
drutter1954 created

I am trying to create a new MAUI app using the latest version of AspNetZero and have followed the step-by-step instructions in the documentation to create a new page for the Blazor mobile app. I have created my proxy in the Application.Client project and in my constructor for my page I call DependencyResolver.Resolve<IExpensesAppService>() but that throws an exception;

No component for supporting the service IExpensesAppService was found.

The proxy (ProxyExpensesAppService) is defined using ProxyAppServiceBase, IExpensesAppService and all of the methods for the interface have been defined appropriately by calling the corresponding await ApiClient... function. As far as I can tell there is no other step required to make the implementation of the interface available.

Please provide information on why the service cannot be resolved.


23 Answer(s)
  • User Avatar
    0
    drutter1954 created

    I found a similar issue #11537 that resolved the initial problem of not resolving service. My proxy was named ProxyExpenseAppService and the interface is IExpensesAppService. Once I changed the proxy name to ProxyExpensesAppService it resolved correctly.

    HOWEVER, when I attempt to make the call to a method on the proxy it never actually executes. I put a breakpoint in the SetBusyAsync method in the {myProject}ComponentBase on the await func(); call and it never hits it. In my InitializedAsync() method I had originally put a call to await UserDialogsService.Block() and it never allowed execution past that call. That same call is the first line of the SetBusyAsync() method and it appears it never goes past that call there either.

    I need to get this working and don't know how to get past this issue.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Could you share ProxyExpenseAppService implementation and how you are calling it ?

  • User Avatar
    0
    drutter1954 created

    Here is the relevant portions of the Proxy:

    using Abp.Application.Services.Dto; using myproject.Dto; using myproject.Expenses.Dtos; using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks;

    namespace myproject.Expenses { public class ProxyExpensesAppService : ProxyAppServiceBase, IExpensesAppService { public async Task CreateOrEdit(CreateOrEditExpenseDto input) { await ApiClient.PostAsync(GetEndpoint(nameof(CreateOrEdit)), input); }

        public async Task Delete(EntityDto&lt;Guid&gt; input)
        {
            await ApiClient.DeleteAsync(GetEndpoint(nameof(Delete)), input);
        }
    
        public async Task&lt;PagedResultDto&lt;GetExpenseForViewDto&gt;> GetActiveForPatient(GetAllExpensesInput input)
        {
            return await ApiClient.GetAsync&lt;PagedResultDto&lt;GetExpenseForViewDto&gt;>(GetEndpoint(nameof(GetActiveForPatient)), input);
        }
    
        public async Task&lt;PagedResultDto&lt;GetExpenseForViewDto&gt;> GetActiveForUser()
        {
            return await ApiClient.GetAsync&lt;PagedResultDto&lt;GetExpenseForViewDto&gt;>(GetEndpoint(nameof(GetActiveForUser)));
        }
    }
    

    }

    Here is the method that calls the proxy:

        private async Task GetList()
        {
            await SetBusyAsync(async () =>
            {
                await WebRequestExecuter.Execute(
                    async () => await _expensesAppService.GetActiveForUser(),
                    (result) =>
                    {
                        pendingExpenses.Clear();
                        approvedExpenses.Clear();
                        deniedExpenses.Clear();
                        foreach (var exp in result.Items)
                        {
                            if (exp.Expense.ApprovalStatus == Enums.CareEventStatuses.Pending)
                            {
                                ExpenseListModel expense = new ExpenseListModel()
                                {
                                    Amount = exp.Expense.Amount,
                                    Payee = exp.Expense.Payee,
                                    ExpenseType = exp.Expense.ExpenseType,
                                    ReceivedDate = exp.Expense.ReceivedDate
                                };
                                pendingExpenses.Add(expense);
                            }
                            else if (exp.Expense.ApprovalStatus == Enums.CareEventStatuses.Approved)
                            {
                                ExpenseListModel expense = new ExpenseListModel()
                                {
                                    Amount = exp.Expense.Amount,
                                    Payee = exp.Expense.Payee,
                                    ExpenseType = exp.Expense.ExpenseType,
                                    ReceivedDate = exp.Expense.ReceivedDate
                                };
                                approvedExpenses.Add(expense);
                            }
                            else
                            {
                                ExpenseListModel expense = new ExpenseListModel()
                                {
                                    Amount = exp.Expense.Amount,
                                    Payee = exp.Expense.Payee,
                                    ExpenseType = exp.Expense.ExpenseType,
                                    ReceivedDate = exp.Expense.ReceivedDate
                                };
                                deniedExpenses.Add(expense);
                            }
                        }
                        return Task.CompletedTask;
                    });
            });
        }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    It all seems fine. Is it possible for you to share your project with [email protected] ?

  • User Avatar
    0
    drutter1954 created

    The email service will not allow sending the project. This is what I am getting when I attempt to execute one of my proxies.

  • User Avatar
    0
    drutter1954 created

    Again, the proxy is never hit. I've restarted Visual Studio and ensured that all applicable patches have been installed. For some reason it doesn't appear to know about the proxy service. Confused and dazed.

  • User Avatar
    0
    drutter1954 created

    I downloaded the starter project again from your website and added my proxy for Expenses into it, add the supporting files in the various projects (dto's and other needed files), added the page and the menu item to access it and it never hits the proxy. Is there some type of registration that has to happen for the proxy to work that I am missing??

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Sometimes Visual Studio might not catch the breakpoint. Could you try deleting bin and obj folders (if you are on a Windows machine, you can use Delete-BIN-OBJ-Folders.bat file), rebuild the solution and try to debug again ?

  • User Avatar
    0
    drutter1954 created

    I have done that a couple times. The latest trial was on a brand new download of the base solution and just adding in the proxy and one page as a test. The app never goes to the page and just hangs after the constructor for the page. Nothing is working in my code.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks. In that case, could you share the classes you have added to an empty solution, so we can reproduce the problem on our side and check it.

  • User Avatar
    0
    drutter1954 created

    using Abp.Application.Services.Dto; using simul_bcfo.Dto; using simul_bcfo.Expenses.Dtos; using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks;

    namespace simul_bcfo.Expenses { public class ProxyExpensesAppService : ProxyAppServiceBase, IExpensesAppService { public async Task CreateOrEdit(CreateOrEditExpenseDto input) { await ApiClient.PostAsync(GetEndpoint(nameof(CreateOrEdit)), input); }

        public async Task Delete(EntityDto&lt;Guid&gt; input)
        {
            await ApiClient.DeleteAsync(GetEndpoint(nameof(Delete)), input);
        }
    
        public async Task&lt;PagedResultDto&lt;GetExpenseForViewDto&gt;> GetActiveForPatient(GetAllExpensesInput input)
        {
            return await ApiClient.GetAsync&lt;PagedResultDto&lt;GetExpenseForViewDto&gt;>(GetEndpoint(nameof(GetActiveForPatient)), input);
        }
    
        public async Task&lt;PagedResultDto&lt;GetExpenseForViewDto&gt;> GetActiveForUser()
        {
            return await ApiClient.GetAsync&lt;PagedResultDto&lt;GetExpenseForViewDto&gt;>(GetEndpoint(nameof(GetActiveForUser)));
        }
    
        public async Task&lt;PagedResultDto&lt;GetExpenseForViewDto&gt;> GetAll(GetAllExpensesInput input)
        {
            return await ApiClient.GetAsync&lt;PagedResultDto&lt;GetExpenseForViewDto&gt;>(GetEndpoint(nameof(GetAll)), input);
        }
    
        public async Task&lt;List&lt;ExpenseCareEventLookupTableDto&gt;> GetAllCareEventForTableDropdown()
        {
            return await ApiClient.GetAsync&lt;List&lt;ExpenseCareEventLookupTableDto&gt;>(GetEndpoint(nameof(GetAllCareEventForTableDropdown)));
        }
    
        public async Task&lt;List&lt;ExpenseExpenseTypeLookupTableDto&gt;> GetAllExpenseTypeForTableDropdown()
        {
            return await ApiClient.GetAsync&lt;List&lt;ExpenseExpenseTypeLookupTableDto&gt;>(GetEndpoint(nameof(GetAllExpenseTypeForTableDropdown)));
        }
    
        public async Task&lt;PagedResultDto&lt;ExpensePatientLookupTableDto&gt;> GetAllPatientForLookupTable(GetAllForLookupTableInput input)
        {
            return await ApiClient.GetAsync&lt;PagedResultDto&lt;ExpensePatientLookupTableDto&gt;>(GetEndpoint(nameof(GetAllPatientForLookupTable)), input);
        }
    
        public async Task&lt;PagedResultDto&lt;ExpensePayeeLookupTableDto&gt;> GetAllPayeeForLookupTable(GetAllForLookupTableInput input)
        {
            return await ApiClient.GetAsync&lt;PagedResultDto&lt;ExpensePayeeLookupTableDto&gt;>(GetEndpoint(nameof(GetAllPayeeForLookupTable)), input);
        }
    
        public async Task&lt;List&lt;ExpensePaymentMethodLookupTableDto&gt;> GetAllPaymentMethodForTableDropdown()
        {
            return await ApiClient.GetAsync&lt;List&lt;ExpensePaymentMethodLookupTableDto&gt;>(GetEndpoint(nameof(GetAllPaymentMethodForTableDropdown)));
        }
    
        public async Task&lt;PagedResultDto&lt;ExpenseUserLookupTableDto&gt;> GetAllUserForLookupTable(GetAllForLookupTableInput input)
        {
            return await ApiClient.GetAsync&lt;PagedResultDto&lt;ExpenseUserLookupTableDto&gt;>(GetEndpoint(nameof(GetAllUserForLookupTable)), input);
        }
    
        public async Task&lt;GetExpenseForEditOutput&gt; GetExpenseForEdit(EntityDto&lt;Guid&gt; input)
        {
            return await ApiClient.GetAsync&lt;GetExpenseForEditOutput&gt;(GetEndpoint(nameof(GetExpenseForEdit)), input);
        }
    
        public async Task&lt;GetExpenseForViewDto&gt; GetExpenseForView(Guid id)
        {
            return await ApiClient.GetAsync&lt;GetExpenseForViewDto&gt;(GetEndpoint(nameof(GetExpenseForView)), id);
        }
    
        public async Task&lt;FileDto&gt; GetExpensesToExcel(GetAllExpensesForExcelInput input)
        {
            return await ApiClient.GetAsync&lt;FileDto&gt;(GetEndpoint(nameof(GetExpensesToExcel)), input);
        }
    
        public async Task RemoveImage1File(EntityDto&lt;Guid&gt; input)
        {
            await ApiClient.PostAsync(GetEndpoint(nameof(RemoveImage1File)), input);
        }
    
        public async Task RemoveImage2File(EntityDto&lt;Guid&gt; input)
        {
            await ApiClient.PostAsync(GetEndpoint(nameof(RemoveImage2File)), input);
        }
    
        public async Task RemoveImage3File(EntityDto&lt;Guid&gt; input)
        {
            await ApiClient.PostAsync(GetEndpoint(nameof(RemoveImage3File)), input);
        }
    }
    

    }

    using System; using System.Threading.Tasks; using Abp.Application.Services; using Abp.Application.Services.Dto; using simul_bcfo.Expenses.Dtos; using simul_bcfo.Dto; using System.Collections.Generic;

    namespace simul_bcfo.Expenses { public interface IExpensesAppService : IApplicationService { Task<PagedResultDto<GetExpenseForViewDto>> GetActiveForUser(); Task<PagedResultDto<GetExpenseForViewDto>> GetActiveForPatient(GetAllExpensesInput input); Task<PagedResultDto<GetExpenseForViewDto>> GetAll(GetAllExpensesInput input);

        Task&lt;GetExpenseForViewDto&gt; GetExpenseForView(Guid id);
    
        Task&lt;GetExpenseForEditOutput&gt; GetExpenseForEdit(EntityDto&lt;Guid&gt; input);
    
        Task CreateOrEdit(CreateOrEditExpenseDto input);
    
        Task Delete(EntityDto&lt;Guid&gt; input);
    
        Task&lt;FileDto&gt; GetExpensesToExcel(GetAllExpensesForExcelInput input);
    
        Task&lt;PagedResultDto&lt;ExpensePayeeLookupTableDto&gt;> GetAllPayeeForLookupTable(GetAllForLookupTableInput input);
    
        Task&lt;List&lt;ExpenseExpenseTypeLookupTableDto&gt;> GetAllExpenseTypeForTableDropdown();
    
        Task&lt;List&lt;ExpensePaymentMethodLookupTableDto&gt;> GetAllPaymentMethodForTableDropdown();
    
        Task&lt;PagedResultDto&lt;ExpensePatientLookupTableDto&gt;> GetAllPatientForLookupTable(GetAllForLookupTableInput input);
    
        Task&lt;List&lt;ExpenseCareEventLookupTableDto&gt;> GetAllCareEventForTableDropdown();
    
        Task&lt;PagedResultDto&lt;ExpenseUserLookupTableDto&gt;> GetAllUserForLookupTable(GetAllForLookupTableInput input);
    
        Task RemoveImage1File(EntityDto&lt;Guid&gt; input);
    
        Task RemoveImage2File(EntityDto&lt;Guid&gt; input);
    
        Task RemoveImage3File(EntityDto&lt;Guid&gt; input);
    
    }
    

    }

    using Microsoft.AspNetCore.Components.Web.Virtualization; //using simul_bcfo.CareEvents; using simul_bcfo.Core.Dependency; using simul_bcfo.Core.Threading; using simul_bcfo.Expenses; using simul_bcfo.Expenses.Dtos; using simul_bcfo.Mobile.MAUI.Models.Expenses; using simul_bcfo.Mobile.MAUI.Shared; using simul_bcfo.Services.Navigation; //using Volo.Abp.Users;

    namespace simul_bcfo.Mobile.MAUI.Pages.Expenses { public partial class Index : simul_bcfoMainLayoutPageComponentBase { protected INavigationService navigationService { get; set; } protected IExpensesAppService _expensesAppService { get; set; } //protected ICareEventsAppService _careEventsAppService { get; set; } protected List<ExpenseListModel> pendingExpenses = new List<ExpenseListModel>(); protected List<ExpenseListModel> approvedExpenses = new List<ExpenseListModel>(); protected List<ExpenseListModel> deniedExpenses = new List<ExpenseListModel>();

        private AddExpenseModal addExpenseModal { get; set; }
        private string showPending = "";
        private string showApproved = "hidden";
        private string showDenied = "hidden";
    
        public Index()
        {
            try
            {
                _expensesAppService = DependencyResolver.Resolve&lt;IExpensesAppService&gt;();
                navigationService = DependencyResolver.Resolve&lt;INavigationService&gt;();
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    
        protected override async Task OnInitializedAsync()
        {
            await SetPageHeader(L("Expenses"));
            //await GetCareEventInfo();
            await GetList();
        }
    
    
        private async Task GetList()
        {
            await SetBusyAsync(async () =>
            {
                await WebRequestExecuter.Execute(
                    async () => await _expensesAppService.GetActiveForUser(),
                    (result) =>
                    {
                        pendingExpenses.Clear();
                        approvedExpenses.Clear();
                        deniedExpenses.Clear();
                        foreach (var exp in result.Items)
                        {
                            if (exp.Expense.ApprovalStatus == Enums.CareEventStatuses.Pending)
                            {
                                ExpenseListModel expense = new ExpenseListModel()
                                {
                                    Amount = exp.Expense.Amount,
                                    Payee = exp.Expense.Payee,
                                    ExpenseType = exp.Expense.ExpenseType,
                                    ReceivedDate = exp.Expense.ReceivedDate
                                };
                                pendingExpenses.Add(expense);
                            }
                            else if (exp.Expense.ApprovalStatus == Enums.CareEventStatuses.Approved)
                            {
                                ExpenseListModel expense = new ExpenseListModel()
                                {
                                    Amount = exp.Expense.Amount,
                                    Payee = exp.Expense.Payee,
                                    ExpenseType = exp.Expense.ExpenseType,
                                    ReceivedDate = exp.Expense.ReceivedDate
                                };
                                approvedExpenses.Add(expense);
                            }
                            else
                            {
                                ExpenseListModel expense = new ExpenseListModel()
                                {
                                    Amount = exp.Expense.Amount,
                                    Payee = exp.Expense.Payee,
                                    ExpenseType = exp.Expense.ExpenseType,
                                    ReceivedDate = exp.Expense.ReceivedDate
                                };
                                deniedExpenses.Add(expense);
                            }
                        }
                        return Task.CompletedTask;
                    });
            });
        }
    }
    

    }

    using System; using Abp.AutoMapper; using simul_bcfo.Expenses.Dtos;

    namespace simul_bcfo.Mobile.MAUI.Models.Expenses { [AutoMapFrom(typeof(ExpenseDto))] public class ExpenseListModel : ExpenseDto { public ExpenseListModel() { } public string AmountAsString { get { return Amount.ToString("$#,##0.00"); } } } } using simul_bcfo.Enums;

    using System; using Abp.Application.Services.Dto; using Abp.Domain.Entities;

    namespace simul_bcfo.Expenses.Dtos { public class ExpenseDto : EntityDto<Guid> { public decimal Amount { get; set; }

        public DateTime ReceivedDate { get; set; }
    
        public string CheckNumber { get; set; }
    
        public string ConfirmationNumber { get; set; }
    
        public string PaymentSequence { get; set; }
    
        public CareEventStatuses ApprovalStatus { get; set; }
    
        public string Note { get; set; }
    
        public Guid? PayeeId { get; set; }
    
        public Guid? ExpenseTypeId { get; set; }
    
        public Guid? PaymentMethodId { get; set; }
    
        public Guid PatientId { get; set; }
    
        public Guid CareEventId { get; set; }
    
        public long? SubmitterId { get; set; }
    
        public string CareEventTitle { get; set; }
        public string Payee { get; set; }
        public string ExpenseType { get; set; }
    }
    

    }

    Here are the classes I added.

    I tried it with JetBrains Rider and got the same result.

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @drutter1954,

    It seems a post method. Not get method. Task<PagedResultDto<GetExpenseForViewDto>> GetActiveForPatient(GetAllExpensesInput input);

    Please use ApiClient.PostAsync method for the request that contains input.

  • User Avatar
    0
    drutter1954 created

    I changed the method to a PostAsync but that doesn't make any difference because it never even gets to the call.

    I am getting errors in the compile stating that several of the classes in the Core.Shared project are not able to be resolved. Also when I attempt to debug the app, I get messages that the proxies source files cannot be found. There is something wrong with the environment, solution or something that I cannot find the cause for.

    Again even starting from scratch I cannot add in anything that resolves at runtime. IF you can tell me how to share my project with you I will be glad to do so. I have used your framework in the past and been happy with the results. This time I am at my wits end trying to get the simplest things to work.

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @drutter1954,

    First, you can delete bin obj and node_modules folders. Then, zip your project and upload it to Gdrive or whatever you want. And share the link with [email protected] (You can also send with WeTransfer)

  • User Avatar
    0
    drutter1954 created

    Good morning. I sent you the link to my solution last week. Have you received the solution and have you gotten it to work? Can you please update me on your progress?

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @drutter1954,

    The e-mail you sent did not reach me. Could you recheck the email?

    Also maybe a screenshot of the mail.

    [email protected]

  • User Avatar
    0
    drutter1954 created

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @drutter1954,

    I request access to the drive file. [email protected]

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @drutter1954,

    I checked your project and there are errors. See screenshot

    After solving these open AddExpenseModal.razor.cs

    Change line 28 to the following code because of the Object reference null problem.

    protected CreateOrEditExpenseModalViewModel Expense = new CreateOrEditExpenseModalViewModel()
    {
        Expense = new CreateOrEditExpenseDto()
    };
    

    After making these changes, it successfully sends a request to the server. I did not find any errors regarding the errors you received. Try again on another computer. Or try formatting the computer. Those errors are not related to aspnetzero.

  • User Avatar
    0
    drutter1954 created

    How did you resolve the errors?? The items that are unresolved are the classes that are part of the base framework. That is the issue that I have been fighting and do not know how to get them resolved.

  • User Avatar
    0
    m.aliozkaya created
    Support Team
    1. Open ExcelImportControllerBase.cs and fix AbpWebConsts.LocalizationSourceName it was AbpWebConsts.LocalizaionSourceName

    2. Open AbpUserLocalizationConfigDtoExtensions.cs and fix simul_bcfoConsts.LocalizationSourceName it was simul_bcfoConstants.LocalizationSourceName

    These were just the problems I experienced. And as I mentioned above open AddExpenseModal.razor.cs

    Change line 28 to the following code because of the Object reference null problem.

    protected CreateOrEditExpenseModalViewModel Expense = new CreateOrEditExpenseModalViewModel()
    {
        Expense = new CreateOrEditExpenseDto()
    };
    

    After making these changes, it successfully sends a request to the server.

  • User Avatar
    0
    drutter1954 created

    Both of those files are generated from AspNetZero's framework. Can you please fix it in the generation process? I have fixed it in my local code. Thanks for finding it.

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    I'm glad your problem was solved. We will fix the bugs in the next version.