So I'm trying to have my application send a string to a text file every minute, So in my Global.asax.cs file I have this setup:
public class Startup
{
public void Configuration(IAppBuilder app)
{
GlobalConfiguration.Configuration
.UseSqlServerStorage("AppContext");
app.UseHangfireDashboard();
app.UseHangfireServer();
}
}
public class HeartbeatSetup
{
public static void Heartbeat()
{
var config = new NLog.Config.LoggingConfiguration();
var logFile = new NLog.Targets.FileTarget() { FileName = "heartbeat.txt", Name = "logfile" };
config.LoggingRules.Add(new NLog.Config.LoggingRule("*", LogLevel.Trace, logFile));
NLog.LogManager.Configuration = config;
var logger = NLog.LogManager.GetCurrentClassLogger();
var currentTime = DateTime.Now.ToString();
RecurringJob.AddOrUpdate("heartbeat", () => logger.Trace("Test"), Cron.Minutely);
}
}
So this create the job ok and runs every minute, but the job does not complete and throws the following error:
No parameterless constructor defined for this object
Does anyone have a solution to this or an alternative method of doing this?