我在MVC3应用程序中使用Quartz.NET是2.2.3。这是我的代码:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
StartScheduler();
}
public static void StartScheduler()
{
ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
IScheduler scheduler = schedulerFactory.GetScheduler();
scheduler.Start();
var jobDetail = new JobDetailImpl("General", null, typeof(Schedule));
var trigger = new SimpleTriggerImpl("SampleTrigger",
null,
DateTime.UtcNow,
null,
SimpleTriggerImpl.RepeatIndefinitely,
TimeSpan.FromHours(24));
scheduler.ScheduleJob(jobDetail, trigger);
}
在首次运行期间,我收到以下错误:
Inheritance security rules violated while overriding member: 'Quartz.Core.QuartzScheduler.InitializeLifetimeService()'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
Source=Quartz TypeName=Quartz.Core.QuartzScheduler.InitializeLifetimeService()
StackTrace:
at Quartz.Impl.StdSchedulerFactory.Instantiate()
at Quartz.Impl.StdSchedulerFactory.GetScheduler()
at Quartz.Impl.StdSchedulerFactory.GetDefaultScheduler()
但是,当我第二次请求时,它会正常运行。请帮我解决这个问题。