111,094
社区成员




Configuration Result:
[Success] Name QuartzServer, [Success] DisplayName Quartz Server, [Success] Desc
ription Quartz Job Scheduling Server, [Success] ServiceName QuartzServer
Topshelf v4.0.0.0, .NET Framework v4.0.30319.42000
The QuartzServer service is now running, press Control+C to exit.
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file contains job definitions in schema version 2.0 format -->
<job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
<processing-directives>
<overwrite-existing-data>true</overwrite-existing-data>
</processing-directives>
<schedule>
<job>
<name>mailJob</name>
<group>mailGroup</group>
<description>Mail job for Quartz Server</description>
<job-type>Quartz.Server.MailJob, Quartz.Server</job-type>
<durable>true</durable>
<recover>false</recover>
</job>
<trigger>
<simple>
<name>mailTrigger</name>
<group>mailGroup</group>
<description>Simple trigger to simply fire sample job</description>
<job-name>mailJob</job-name>
<job-group>mailGroup</job-group>
<misfire-instruction>SmartPolicy</misfire-instruction>
<repeat-count>-1</repeat-count>
<repeat-interval>10000</repeat-interval>
</simple>
</trigger>
<job>
<name>sampleJob</name>
<group>sampleGroup</group>
<description>Sample job for Quartz Server</description>
<job-type>Quartz.Server.SampleJob, Quartz.Server</job-type>
<durable>true</durable>
<recover>false</recover>
</job>
<trigger>
<simple>
<name>sampleSimpleTrigger</name>
<group>sampleSimpleGroup</group>
<description>Simple trigger to simply fire sample job</description>
<job-name>sampleJob</job-name>
<job-group>sampleGroup</job-group>
<misfire-instruction>SmartPolicy</misfire-instruction>
<repeat-count>-1</repeat-count>
<repeat-interval>10000</repeat-interval>
</simple>
</trigger>
</schedule>
</job-scheduling-data>
using System;
using System.Threading;
using Common.Logging;
namespace Quartz.Server
{
/// <summary>
/// A sample job that just prints info on console for demostration purposes.
/// </summary>
public class SampleJob : IJob
{
private static readonly ILog logger = LogManager.GetLogger(typeof(SampleJob));
/// <summary>
/// Called by the <see cref="IScheduler" /> when a <see cref="ITrigger" />
/// fires that is associated with the <see cref="IJob" />.
/// </summary>
/// <remarks>
/// The implementation may wish to set a result object on the
/// JobExecutionContext before this method exits. The result itself
/// is meaningless to Quartz, but may be informative to
/// <see cref="IJobListener" />s or
/// <see cref="ITriggerListener" />s that are watching the job's
/// execution.
/// </remarks>
/// <param name="context">The execution context.</param>
public void Execute(IJobExecutionContext context)
{
logger.Info("SampleJob running...");
Thread.Sleep(TimeSpan.FromSeconds(5));
logger.Info("SampleJob run finished.");
}
}
}
<configSections>
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
x.SetDescription(Configuration.ServiceDescription);报错了
“System.TypeInitializationException”类型的异常在 Quartz.exe 中发生,但未在用户代码中进行处理
其他信息: “Quartz.Server.Configuration”的类型初始值设定项引发异常。
HostFactory.Run(x =>
{
x.RunAsLocalSystem();
x.SetDescription(Configuration.ServiceDescription);
x.SetDisplayName(Configuration.ServiceDisplayName);
x.SetServiceName(Configuration.ServiceName);
x.Service(factory =>
{
QuartzServer server = QuartzServerFactory.CreateServer();
server.Initialize();
return server;
});
});
using System.IO;
using Topshelf;
namespace Quartz.Server
{
/// <summary>
/// The server's main entry point.
/// </summary>
public static class Program
{
/// <summary>
/// Main.
/// </summary>
public static void Main()
{
// change from service account's dir to more logical one
Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);
HostFactory.Run(x =>
{
x.RunAsLocalSystem();
x.SetDescription(Configuration.ServiceDescription);
x.SetDisplayName(Configuration.ServiceDisplayName);
x.SetServiceName(Configuration.ServiceName);
x.Service(factory =>
{
QuartzServer server = QuartzServerFactory.CreateServer();
server.Initialize();
return server;
});
});
}
}
}
HostFactory.Run(x =>
{
x.RunAsLocalSystem();
x.SetDescription(Configuration.ServiceDescription);
x.SetDisplayName(Configuration.ServiceDisplayName);
x.SetServiceName(Configuration.ServiceName);
x.Service(factory =>
{
QuartzServer server = QuartzServerFactory.CreateServer();
server.Initialize();
return server;
});
});
你的programe里有这段代码吗?