I have one problem which refers to quartz.net cron expressions. I have read many articles and tried many pieces of code but without any results, so I feel little bit hopeless and that's why I decided to ask You. Maybe somebody also had similar problem. Is any way to parse cron expression for Quartz.Net to DateTime format? For example I have a cron:

var cron = new Quartz.CronExpression("0 * 8-22 * * ?");

I have tried use GetFinalFireTime() GetTimeAfter() GetNextValidTimeAfter() but application still throws exception:

An unhandled exception of type 'System.AccessViolationException' occurred. Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Here is my code:

CronExpression cron = new Quartz.CronExpression("0 * 8-22 * * ?");
DateTimeOffset? nextFire = cron.GetNextValidTimeAfter(dt);

I also will be very thankful if you can tell me if is there any cron parser library which allows to create crons easy. Something similar to cronMaker.com but proper working with Quartz.Net.

有帮助吗?

解决方案

GetFinalFireTime hasn't been implemented yet.
GetNextValidTimeAfter should be working if you're using one of the latest versions.

If you want to generate cron expressions in c# you can use CronScheduleBuilder.

UPDATE:

You can find a simple project here (QuartzNetCronExpressions.zip) where you can see how it works.

NOTE: I've used VS 2013, Framework 4.5.1 and Quartz.net 2.2.1 (nuget package).

其他提示

I was facing this same problem.Somehow my project configuration for build was set x86. It was not giving me option to change it.I unloaded project and changed it in notepad.Build configuration was set as "AnyCPU" and things started working Problem Solved

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top