【问题标题】:The type initializer for 'Quartz.Impl.StdSchedulerFactory' threw an exception'Quartz.Impl.StdSchedulerFactory' 的类型初始化器抛出异常
【发布时间】:2011-11-03 15:43:04
【问题描述】:

我非常严格地按照 Quartz.Net's tutorial 上的说明进行操作,但在尝试调试我的项目时出现启动错误。

 The type initializer for 'Quartz.Impl.StdSchedulerFactory' threw an exception.

我真的在网上找不到任何帮助。这是配置问题吗?有人知道我在哪里可以得到需要配置的简单列表吗?

(我使用的是 Quartz.Net 2.0)

内部异常:{“无法从配置部分 'common/logging' 获取 Common.Logging 的配置。”}

【问题讨论】:

  • 什么是内部异常?

标签: c# quartz-scheduler quartz.net typeinitializeexception


【解决方案1】:

您很可能没有引用所有必需的程序集,例如“Common.Logging.dll”。

更新

构造函数失败,因为您的app.configweb.config 不包含common\logging 的部分。您的.config 文件是否包含以下部分:

  <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>

【讨论】:

  • 我引用 Quartz.dll、Common.Logging.dll 和 C5
  • 由于静态构造函数失败而发生错误。 StdSchedulerFactory 中唯一的外部引用是 Common.Logging private static readonly ILog Log = LogManager.GetLogger(typeof (StdSchedulerFactory)); 是“Common.Logging.dll”复制到您的输出文件夹。您能否发布内部异常。
  • Common.Logging.dll 在我的输出文件夹中。请参阅我对内部异常的编辑。
  • 我的 app.config 文件中逐字记录了这些内容。还是不行。
  • 我不知道为什么要使用正确的配置。你可以把你的项目上传到某个地方,让我看看。
【解决方案2】:

就我而言,它是 Quartz.net 的版本。

最初我使用了最新版本的 Quartz.net 并且遇到了同样的错误。现在我正在使用:

  • Common.Logging 2.1.2.0
  • Common.Logging.Log4Net1211 2.1.0.0
  • log4net 1.2.11.0
  • 石英 2.2.2.400

【讨论】:

    【解决方案3】:

    检查您是否在解决方案中添加了对Common.Logging.Log4Net dll 的引用。

    如果没有,您可以在Quartz.NET-2.0.1\lib\2.0 中找到兼容的Common.Logging.Log4Net dll:

    Download Quartz.NET-2.0.1.zip (9.7 MB)

    另外,您可能需要使用 log4net 版本 1.2.10.0

    【讨论】:

      猜你喜欢
      • 2011-04-16
      • 1970-01-01
      • 1970-01-01
      • 2018-04-05
      • 1970-01-01
      • 2021-07-09
      • 1970-01-01
      相关资源
      最近更新 更多