c# - Hangfire ASP.NET Core 包
问题描述
我已经安装了软件包:
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
。
解决方案
该Main
方法之前运行Configure
,ConfigureServices
因此您尝试Hangfire
在配置发生之前使用。
推荐阅读
- vue.js - 如何将图像路径从标签传递到 Vue 组件
- c++ - 为单元测试调用继承类的私有成员
- python - 我需要制作一个 python 项目,但我知道 C#,但不知道如何转换它
- python - 在命令行中运行 python 文件没有输出
- c# - .net MVC中是否有任何方法可以将数据库日期导出到不在本地机器中的文件中,并作为文件附件与电子邮件一起发送。?
- sql - 为什么在窗口函数中使用 GROUP BY
- sql - SQL Server 中的 AVG
- java - 处理中带有 loadPixels() 的渐变
- python - 使用 VScode (python) 键入提示错误
- javascript - 重写_.invoke