【发布时间】:2020-09-21 18:26:31
【问题描述】:
我只是想用 ABP.IO 项目和 Hangfire 运行后台作业(我已经用 aspnetboilerplate 完成了,没有任何问题)
每次我的循环作业开始时都会抛出这个错误:
A suitable constructor for type 'AbpIo.TachePlan.ITachePlanifiee' could not be located.
对于这个测试,我只是在 Contracts 项目中编写一个接口
using System;
using System.Collections.Generic;
using System.Text;
namespace AbpIo.TachePlan
{
public interface ITachePlanifiee
{
void Test();
}
}
以及应用项目中的实现
using System;
using System.Collections.Generic;
using System.Text;
namespace AbpIo.TachePlan
{
public class TachePlanifiee : ITachePlanifiee
{
public TachePlanifiee()
{ }
public void Test()
{
//Great job
}
}
}
在网络项目中
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
//default ABP.IO code
app.UseHangfireDashboard();
RecurringJob.AddOrUpdate<ITachePlanifiee>(x=> x.Test(), "*/15 * * * *");
}
但结果是
System.InvalidOperationException
A suitable constructor for type 'AbpIo.TachePlan.ITachePlanifiee' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.
System.InvalidOperationException: A suitable constructor for type 'AbpIo.TachePlan.ITachePlanifiee'
could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetServiceOrCreateInstance(IServiceProvider provider, Type type)
at Hangfire.AspNetCore.AspNetCoreJobActivatorScope.Resolve(Type type)
at Hangfire.Server.CoreBackgroundJobPerformer.Perform(PerformContext context)
at Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass9_0.<PerformJobWithFilters>b__0()
at Hangfire.Server.BackgroundJobPerformer.InvokePerformFilter(IServerFilter filter, PerformingContext preContext, Func`1 continuation)
at Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass9_1.<PerformJobWithFilters>b__2()
at Hangfire.Server.BackgroundJobPerformer.PerformJobWithFilters(PerformContext context, IEnumerable`1 filters)
at Hangfire.Server.BackgroundJobPerformer.Perform(PerformContext context)
at Hangfire.Server.Worker.PerformJob(BackgroundProcessContext context, IStorageConnection connection, String jobId)
我需要帮助,因为我不明白我的错误在哪里
问候
【问题讨论】:
-
显示接口定义
-
显示为您的接口注册服务的位置...
标签: hangfire abp hangfire-autofac