【发布时间】:2018-12-26 03:13:57
【问题描述】:
我已经安装了软件包:
Hangfire.AspNetCore
Hangfire.MemoryStorage.Core
这是我的代码:
using Hangfire;
using Hangfire.MemoryStorage;
public void ConfigureServices(IServiceCollection services)
{
services.AddHangfire(c => c.UseStorage(GlobalConfiguration.Configuration.UseMemoryStorage()));
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseHangfireServer();
}
...
public static void Main(string[] args)
{
RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Minutely);
}
但是,我得到了错误:
JobStorage.Current property value has not been initialized. You must set it before using Hangfire Client or Server API.
我的应用程序正在ASP.NET Core 上运行。
【问题讨论】:
-
不,因为即使使用这些建议的解决方案,我也遇到了问题。
-
RecurringJob.AddOrUpdate看起来像一个静态方法。您没有初始化 asp.net 核心管道 -
稍后尝试将
RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Minutely);移动到app.UseHangfireServer();。
标签: c# asp.net-core hangfire