0

I am using Visual Studio 2019, and these are the versions I have:

  • Common.Logging: 3.2.0.0
  • Log4Net: 2.0.8.0
  • Quartz: 2.3.3.0

The line of my code where errors appear is this: programador = fProgramacion.GetScheduler();

The errors are these:

System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'Quartz.Impl.StdSchedulerFactory' threw an exception.
Source=Quartz
StackTrace:
at Quartz.Impl.StdSchedulerFactory.get_Log()
at Quartz.Impl.StdSchedulerFactory.Initialize()
at Quartz.Impl.StdSchedulerFactory.GetScheduler()
at MSM.RealTime.Programador.iniciar() in C:\\Users\\SCC_EXT_1\\Source\\Repos\\MSM_Web\\MSM\\RealTime\\Programador.cs:line 24
at MSM.WebApiApplication.Application_Start() in C:\\Users\\SCC_EXT_1\\Source\\Repos\\MSM_Web\\MSM\\Global.asax.cs:line 30

Inner Exception 1:
ConfigurationException: Failed obtaining configuration for Common.Logging from configuration section 'common/logging'.

Inner Exception 2:
ConfigurationErrorsException: An error occurred creating the configuration section handler for common/logging: Unable to create type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net' (C:\\Users\\SCC_EXT_1\\Source\\Repos\\MSM_Web\\MSM\\web.config line 29)

Inner Exception 3:
ConfigurationException: Unable to create type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net'

Inner Exception 4:
FileNotFoundException: Could not load file or assembly 'Common.Logging.Log4net' or one of its dependencies. The system cannot find the file specified.

These are the data of my web.config and log4net.config:

Web.config

<configSections>
      <section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <sectionGroup name="common">
           <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
      </sectionGroup>
 </configSections>
 <common>
    <logging>
          <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
                <arg key="configType" value="INLINE"/>
          </factoryAdapter>
    </logging>
</common>

log4net.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!--Log4Net -->
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" />
  </configSections>

  <log4net>
    <root>
      <!--"ALL/DEBUG/INFO/WARN/ERROR/FATAL/OFF"-->
      <level value="ALL" />
      <appender-ref ref="LogFileAppender" />
    </root>
    
    <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
      <param name="File" value="logs.txt" />
      <param name="AppendToFile" value="true" />
      <!-- Logfiles are rolled over to backup files when size limit is reached -->
      <rollingStyle value="Size" />
      <!-- Maximum number of backup files that are kept before the oldest is erased -->
      <maxSizeRollBackups value="10" />
      <!-- Maximum size that the output file is allowed to reach before being rolled over to backup files -->
      <maximumFileSize value="10MB" />
      <!-- Indicating whether to always log to the same file -->
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%-5p%d{yyyy-MM-dd hh:mm:ss} – %m%n" />
      </layout>
    </appender>
  </log4net>
</configuration>

Anyone Knows if the problem is about the versions because they are incompatible? I have seen I do not have the Common.Logging.Log4Net.dll.

Thanks a lot

0 Answers0