【问题标题】:Hangfire: The type does not contain a method with signatureHangfire:该类型不包含带有签名的方法
【发布时间】:2018-01-02 17:47:23
【问题描述】:

我有一个 Web 应用程序,它具有 Page1.aspx,它执行 task1,然后以 fireAndforget 方式将 task2 排入调度程序。

我正在使用 Hangfire,当doLongJob() 没有参数(测试时)时,所有东西都已安装并正常工作,但只有一次。然后我添加了一个参数(我将添加更多)。 之后我面对这些errors

Page1.aspx.cs

string strMsgID = //task1 returns a value;
BackgroundJob.Enqueue(() => doLongJob(strMsgID));

public void doLongJob(string strMsgID)
{
    int status = //task2(strMsgID);
    while( status == 2)
    {
        Thread.Sleep(10000);
        status = //task2(strMsgID);
        }
    }
}

Startup.cs

using Hangfire;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(erp.Startup))]
namespace erp
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {

            app.UseHangfireDashboard();

            app.UseHangfireServer();

        }
    }
}

Global.asax.cs

protected void Application_Start(object sender, EventArgs e)
{
    GlobalConfiguration.Configuration.UseStorage(new MySqlStorage("hangfire"));
}

【问题讨论】:

  • 我遇到了类似的问题,结果我正在连接到不同的存储
  • 如何识别?

标签: c# hangfire fire-and-forget


【解决方案1】:

我遇到了类似的问题,结果是存储连接问题。

在您的代码中,我认为您传递的是字符串 "hangfire",而您应该传递连接字符串

GlobalConfiguration.Configuration.UseStorage(new MySqlStorage(connectionString));

你可以通过hangfirehere找到更多的MySQL配置选项

【讨论】:

【解决方案2】:

您是否仔细检查了失败作业的日期?

我也遇到过类似的问题 - 原来我只是在看以前同样失败的工作。因为这是最近失败的工作,所以我没想过要检查它是否比看起来更旧。

【讨论】:

  • 是的...我也使用DateTime 来打印日期和时间。
猜你喜欢
  • 2022-05-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-03
  • 2022-08-17
  • 2020-11-08
  • 1970-01-01
  • 2022-01-25
相关资源
最近更新 更多