Question

I'm trying to set up Quartz.NET in an Azure worker role for scheduling a daily events. After much trial and error, I've found that the inclusion of one line of code within the target method is causing the event to not get triggered at all

Building off the Quartz.NET example, I have an IJob class the the overridden Execute method (registered with a scheduler & trigger).

When the offending line (commented) is removed, I can hit the breakpoint on the Trace.WriteLine statement. With it present, the breakpoint will never be hit, and the output isn't present elsewhere.

The code:

public class MyUpdaterJob : IJob
{
    public MyUpdaterJob()
    {
    }

    public void Execute(JobExecutionContext context)
    {
        Trace.WriteLine("-- Yay - Job called");

        // Removing this line will result in the breakpoint above being able to be hit
        MyUpdateWorker updateWorker = new MyUpdateWorker();

        var logDate = context.FireTimeUtc.Value.AddHours(-1);

        // [...]
    }
}

I'm at quite a loss as to what it might be evaluating that would cause it to not trigger this event. Any suggestions?

  • The 'MyUpdateWorker' is in another library
  • This is currently running as an Azure Worker Role
Was it helpful?

Solution 2

Wow - this was an odd one.

As a result of the 'organic' growth of this project, the library containing the IJob implementation was previously a console app, which I'd switched the output over to 'class library' a few weeks prior.

The Platform target was set to (any only had available) x86. Everything else was compiling as 'Any CPU', and probably 64 bit.

I recall I had to manually edit the .csproj file to update this, but once that former-console-project-now-library was set to Any CPU, it now triggers correctly!

OTHER TIPS

I think I'd check the constructor for your MyUpdateWorker() class to see if that all works ok, perhaps have a log at the diagnostic logs to see if you can something in there that would indicate the cause. Normally I see problems with missing libraries on Azure so perhaps there is a missing dependency.

Just a few things to check (only had two coffees this morning so I'm still warming up)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top