激活Castle.Proxies.AlertAppServiceProxy时引发异常



我正试图利用Book and Author abp教程来构建一个示例应用程序。

在我的示例应用程序中,我有网站(而不是书籍(和提醒(而不是作者(。

一切似乎都很好。但是,当我加载/alers页面时,我会收到以下错误。

正在寻找解决问题的方向。。。。

我最接近的链接是: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)
);
}
}
}

如果未设置模型的DBSet,也可能发生此错误。

public DbSet<Alert> Alerts {get;set;}

最新更新