【问题标题】:Downgrade log4net from 2.0.8 to 2.0.0 and getting an unhandled exception before code runs将 log4net 从 2.0.8 降级到 2.0.0 并在代码运行之前获得未处理的异常
【发布时间】:2019-07-31 12:46:00
【问题描述】:

我正在尝试将我的项目中的 log4net 从 2.0.8 降级到 2.0.0,因为我正在尝试引用版本为 2.0.0 的项目,我需要这样做,因为Apache changed the public key between these versions.

我的问题是降级后尝试运行项目时出现以下错误:

An unhandled exception of type 'System.TypeInitializationException' occurred 
in Unknown Module.
The type initializer for '<Module>' threw an exception. occurred

我看不到内部异常,因为错误发生在任何代码被命中之前。

如果我将 log4net 升级回 2.0.8,错误就会停止发生。

I've tried this solution 但没有运气。

【问题讨论】:

    标签: .net nuget log4net visual-studio-2019


    【解决方案1】:

    在我写这个问题时,我设法找出了问题所在。

    log4net 2.0.8 版将以下“dependentAssembly”添加到您的项目 app.config 文件中,并且在降级时它不会被删除。

    从 app.config 中删除它解决了我的问题。

      <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.8.0" newVersion="2.0.8.0" />
      </dependentAssembly>
    

    希望这对其他人有所帮助。

    【讨论】:

      猜你喜欢
      • 2021-08-22
      • 2020-04-17
      • 2019-08-10
      • 2021-01-03
      • 2017-04-15
      • 2020-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多