【发布时间】:2019-03-05 16:09:40
【问题描述】:
我用 Nuget 安装了hangfire。
PM> Install-Package Hangfire
然后用以下几行更新 OWIN Startup 类:
public void Configuration(IAppBuilder app)
{
GlobalConfiguration.Configuration.UseSqlServerStorage("MySqlConnection");
app.UseHangfireDashboard();
app.UseHangfireServer();
}
我将web.config上的连接字符串名称命名为UseSqlServerStorage中的connectionString名称。
web.config:
<connectionStrings>
<add name="MyEntities" connectionString="metadata=res://*/CRMModelContext.csdl|res://*/CRMModelContext.ssdl|res://*/CRMModelContext.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=xxx;persist security info=True;user id=sa;password=123;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="MySqlConnection" connectionString="User ID=sa;Initial Catalog=xxx;Password=123;Integrated Security=False;Data Source=." />
SQL Server 2008 R2 已安装在系统上,但挂火的数据库不在其中。
最后,当我运行程序时,出现以下错误。
我的工作:
BackgroundJob.Enqueue<Receiver>(x=>x.EmailReceiving());
RecurringJob.AddOrUpdate<Receiver>(x => x.EmailReceiving(), Cron.MinuteInterval(15));
错误:
JobStorage.Current property value has not been initialized. You must set it before using Hangfire Client or Server API.
【问题讨论】:
标签: hangfire