2

我刚刚更新了我的 nuget 包Common.Logging.Log4Net。从那时起,我不断收到以下错误:

无法从程序集“Common.Logging,版本=2.2.0.0,文化=中性,PublicKeyToken=af08829b84f0328e”加载类型“Common.Logging.Factory.AbstractCachingLoggerFactoryAdapter”

以下是链接到的每个 nuget 包的列表Common.Logging以及版本:

  • Common.Logging - 2.2.0
  • Common.Logging.Core - 2.2.0
  • Common.Logging.Log4Net - 2.0.1

在我的 web.config 我有以下位:

<configuration>
  <configSections>
   <sectionGroup name="common">
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
    </sectionGroup>
  </configSections>

  //...//

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

  //...//

  <common>
    <logging>
      <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net">
        <arg key="configType" value="FILE-WATCH" />
        <arg key="configFile" value="~/log4net.config" />
      </factoryAdapter>
    </logging>
  </common>
</configuration>

我怎样才能解决这个问题?

我试过改变:

<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net">

到(Common.Logging.Log4net.dll [201] 的添加版本)

<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net201">

那没有用。

4

2 回答 2

5

所以我找到了我的问题的答案,并想与遇到同样问题的任何人分享答案。

看起来Common.Logging 2.1.2Common.Logging 2.2.0开发者之间做了一个改变来创建一个新的库Common.Logging.Core。根据 Common.Logging 开发 (GitHub) 站点,该Common.Logging.Log4Net包尚未更新以支持新更改。

于 2014-07-25T16:08:35.543 回答
0

另一个可能对某些人有帮助的观点:

从 Common.Logging 3.0 开始,开发人员改变了他们处理版本依赖关系的方式,例如,不再支持组件 Common.Logging.Log4Net,每个框架现在都需要版本特定的引用。因此,对于 Common.Logging.Log4Net,对于本文的最新版本,它将是 Common.Logging.Log4Net1213。

使用 nuget,您可以通过以下方式获得:

Install-Package Common.Logging.Log4Net1213

更多信息可以在这里找到。

于 2015-05-24T15:47:12.750 回答