Возникло исключение при активации Castle.Proxies.AlertAppServiceProxy

Я пытаюсь использовать учебник Book and Author abp для создания примера приложения.

В моем примере приложения есть сайты (а не книги) и оповещения (а не авторы).

Вроде бы все правильно. Однако, как только я загружаю страницу /alerts, я получаю следующую ошибку.

Ищу какое-то направление в том, как решить ....

Самое близкое, что я нашел, это эта ссылка: 58321986#58321986">Исключение Abp.io: возникло исключение при активации Castle.Proxies.ProcessesServiceProxy

Однако я не уверен, что именно этот пользователь сделал для решения своей проблемы.

[14:56:47 INF] Authorization was successful.
[14:56:47 INF] Executing endpoint 'MyApp.Alerts.AlertAppService.GetListAsync (MyApp.Application)'
[14:56:47 INF] Route matched with {action = "GetList", controller = "Alert", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.Application.Dtos.PagedResultDto`1[MyApp.Alerts.AlertDto]] GetListAsync(Volo.Abp.Application.Dtos.PagedAndSortedResultRequestDto) on controller MyApp.Alerts.AlertAppService (MyApp.Application).
[14:56:47 ERR] ---------- RemoteServiceErrorInfo ----------
{
  "code": null,
  "message": "An internal error occurred during your request!",
  "details": null,
  "data": {
    "ActivatorChain": "Castle.Proxies.AlertAppServiceProxy"
  },
  "validationErrors": null
}

[14:56:47 ERR] An exception was thrown while activating Castle.Proxies.AlertAppServiceProxy.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.AlertAppServiceProxy.
 ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Volo.Abp.Autofac.AbpAutofacConstructorFinder' on type 'Castle.Proxies.AlertAppServiceProxy' can be invoked with the available services and parameters:
Cannot resolve parameter 'MyApp.Sites.ISiteRepository siteRepository' of constructor 'Void .ctor(Castle.DynamicProxy.IInterceptor[], Volo.Abp.Domain.Repositories.IRepository`2[MyApp.Alerts.Alert,System.Guid], MyApp.Sites.ISiteRepository)'.
   at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.ReflectionActivator.<ConfigurePipeline>b__11_0(ResolveRequestContext ctxt, Action`1 next)
   at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Builder.RegistrationBuilder`3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action`1 next)
   at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   --- End of inner exception stack trace ---
   at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Builder.RegistrationBuilder`3.<>c__DisplayClass35_0.<OnPreparing>b__0(ResolveRequestContext ctxt, Action`1 next)
   at Autofac.Core.Resolving.Middleware.CoreEventMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)
   at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request)
   at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
   at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
   at Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext)
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)[14:56:47 ERR] ---------- Exception Data ----------
ActivatorChain = Castle.Proxies.AlertAppServiceProxy

[14:56:47 INF] Executing ObjectResult, writing value of type 'Volo.Abp.Http.RemoteServiceErrorResponse'.
[14:56:47 INF] Executed action MyApp.Alerts.AlertAppService.GetListAsync (MyApp.Application) in 4.1234ms
[14:56:47 INF] Executed endpoint 'MyApp.Alerts.AlertAppService.GetListAsync (MyApp.Application)'

РЕДАКТИРОВАТЬ: Вот ISiteRepository.cs в MyApp.Domain/Sites/

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;

namespace MyApp.Sites
{
    public interface ISiteRepository : IRepository<Site, Guid>
    {
        Task<Site> FindByNameAsync(string company);

        Task<List<Site>> GetListAsync(
            int skipCount,
            int maxResultCount,
            string sorting,
            string filter = null
        );
    }
}

РЕДАКТИРОВАТЬ 2: Регистрация ISiteRepository (я думаю) - в MyApp.Application/Alerts/AlertAppService.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MyApp.Sites;
using MyApp.Permissions;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;

namespace MyApp.Alerts
{
    [Authorize(MyAppPermissions.Alerts.Default)]
    public class AlertAppService :
        CrudAppService<
            Alert, //The  Alert entity
            AlertDto, //Used to show  alerts
            Guid, //Primary key of the  alert entity
            PagedAndSortedResultRequestDto, //Used for paging/sorting
            CreateUpdateAlertDto>, //Used to create/update a  alert
        IAlertAppService //implement the IAlertAppService
    {
        private readonly ISiteRepository _siteRepository;

        public AlertAppService(
            IRepository<Alert, Guid> repository,
            ISiteRepository siteRepository)
            : base(repository)
        {
            _siteRepository = siteRepository;
            GetPolicyName = MyAppPermissions.Alerts.Default;
            GetListPolicyName = MyAppPermissions.Alerts.Default;
            CreatePolicyName = MyAppPermissions.Alerts.Create;
            UpdatePolicyName = MyAppPermissions.Alerts.Edit;
            DeletePolicyName = MyAppPermissions.Alerts.Delete;
        }


        public override async Task<AlertDto> GetAsync(Guid id)
        {
            //Get the IQueryable<Alert> from the repository
            var queryable = await Repository.GetQueryableAsync();

            //Prepare a query to join sites and alerts
            var query = from Alert in queryable
                        join site in _siteRepository on Alert.SiteId equals site.Id
                        where Alert.Id == id
                        select new { Alert, site };

            //Execute the query and get the Alert with site
            var queryResult = await AsyncExecuter.FirstOrDefaultAsync(query);
            if (queryResult == null)
            {
                throw new EntityNotFoundException(typeof(Alert), id);
            }

            var AlertDto = ObjectMapper.Map<Alert, AlertDto>(queryResult.Alert);
            AlertDto.SiteName = queryResult.site.Name;
            return AlertDto;
        }

        public override async Task<PagedResultDto<AlertDto>> GetListAsync(PagedAndSortedResultRequestDto input)
        {
            //Set a default sorting, if not provided
            if (input.Sorting.IsNullOrWhiteSpace())
            {
                input.Sorting = nameof(Alert.SiteName);
            }

            //Get the IQueryable<Book> from the repository
            var queryable = await Repository.GetQueryableAsync();

            //Prepare a query to join Alerts and sites
            var query = from Alert in queryable
                        join site in _siteRepository on Alert.SiteId equals site.Id
                        orderby input.Sorting //TODO: Can not sort like that!
                        select new { Alert, site };

            //Paging
            query = query
                .Skip(input.SkipCount)
                .Take(input.MaxResultCount);

            //Execute the query and get a list
            var queryResult = await AsyncExecuter.ToListAsync(query);

            //Convert the query result to a list of AlertDto objects
            var AlertDtos = queryResult.Select(x =>
            {
                var AlertDto = ObjectMapper.Map<Alert, AlertDto>(x.Alert);
                AlertDto.SiteName = x.site.Name;
                return AlertDto;
            }).ToList();

            //Get the total count with another query
            var totalCount = await Repository.GetCountAsync();

            return new PagedResultDto<AlertDto>(
                totalCount,
                AlertDtos
            );
        }

        public async Task<ListResultDto<SiteLookupDto>> GetSiteLookupAsync()
        {
            var sites = await _siteRepository.GetListAsync();

            return new ListResultDto<SiteLookupDto>(
                ObjectMapper.Map<List<Site>, List<SiteLookupDto>>(sites)
            );
        }
    }
}

abp
person KevinL    schedule 01.04.2021    source источник
comment
Как вы пытались зарегистрировать ISiteRepository?   -  person aaron    schedule 02.04.2021
comment
@aaron Я добавил код ISiteRepository выше...   -  person KevinL    schedule 02.04.2021
comment
Как насчет реализации и регистрации?   -  person aaron    schedule 02.04.2021
comment
@aaron - см. редактирование № 2. Я думаю, это то, о чем вы просите....   -  person KevinL    schedule 02.04.2021
comment
Это инъекция и использование.   -  person aaron    schedule 03.04.2021
comment
Прочтите docs.abp.io/en/abp/latest/Dependency-Injection, который также охватывает как обычную, так и ручную регистрацию.   -  person aaron    schedule 03.04.2021
comment
Вы нашли решение этой проблемы?   -  person Sam A    schedule 11.04.2021
comment
Решение состоит в том, чтобы реализовать и зарегистрировать конкретный класс для интерфейса.   -  person aaron    schedule 12.04.2021
comment
@aaron - я просто не мог ответить на прошлой неделе. Я, конечно, не в себе, поскольку я следил за учебником, который, по-видимому, не освещал, где и как реализовать и зарегистрировать интерфейс. Я перечитал ссылку несколько раз, и мои глаза пересекаются. Не могли бы вы помочь мне пройти через этот процесс еще немного?   -  person KevinL    schedule 13.04.2021
comment
@SamA - похоже, что Аарон в порядке, я просто не понял, как это исправить, следуя документации.   -  person KevinL    schedule 13.04.2021
comment
@KevinL Можете ли вы дать ссылку на учебник?   -  person aaron    schedule 13.04.2021
comment
@aaron - вот ссылка на учебник: docs.abp.io/en/abp/latest/Tutorials/Part-10?UI=NG&DB=EF   -  person KevinL    schedule 14.04.2021
comment
@KevinL Вы имеете в виду IAuthorRepository? Реализация описана в предыдущей части этого руководства: docs.abp.io/en/abp/latest/Tutorials/Part-7?UI=NG&DB=EF   -  person aaron    schedule 15.04.2021
comment
@aaron, ты потрясающий! Это был недостающий ингредиент. Не знаю, как я пропустил это, но я сделал!   -  person KevinL    schedule 16.04.2021