问题
I'm following the directions on Quartz.Net's tutorial pretty closely, but I'm getting a start error when trying to debug my project.
The type initializer for 'Quartz.Impl.StdSchedulerFactory' threw an exception.
I couldn't really find any help online. Is this a configuration problem? Anybody know where I can get a straightforward list of what needs to be configured?
(I'm using Quartz.Net 2.0)
INNER EXCEPTION: {"Failed obtaining configuration for Common.Logging from configuration section 'common/logging'."}
回答1:
You most likely do not reference all required assemblies e.g. "Common.Logging.dll".
Update
The constructor fails because your app.config
or web.config
does not contain a section for common\logging
. Does your .config
file contains the following section:
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
<arg key="level" value="DEBUG" />
<arg key="showLogName" value="true" />
<arg key="showDataTime" value="true" />
<arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" />
</factoryAdapter>
</logging>
</common>
回答2:
In my case it was the version of the Quartz.net.
Initially I used the latest version of Quartz.net and had the same error. Now I am using:
- Common.Logging 2.1.2.0
- Common.Logging.Log4Net1211 2.1.0.0
- log4net 1.2.11.0
- Quartz 2.2.2.400
回答3:
Check that you have added a reference to Common.Logging.Log4Net
dll in your solution.
If not you can find a compatible Common.Logging.Log4Net
dll in Quartz.NET-2.0.1\lib\2.0
:
Download Quartz.NET-2.0.1.zip (9.7 MB)
Also you might need to use log4net version 1.2.10.0
.
来源:https://stackoverflow.com/questions/7997725/the-type-initializer-for-quartz-impl-stdschedulerfactory-threw-an-exception