2017-10-06 5 views
0

Je reçois ci-dessous erreur lors de l'initialisation StdSchedulerFactory dans Quartz.netImpossible d'initialiser StdSchedulerFactory à quartz dot net

The type initializer for 'Quartz.Impl.StdSchedulerFactory' threw an exception 
{"Could not load file or assembly 'Common.Logging, Version=3.3.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The system cannot find the file specified.":"Common.Logging, Version=3.3.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e"} 
fusionlog: === Pre-bind state information === 
LOG: DisplayName = Common.Logging, Version=3.3.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e 
(Fully-specified) 
LOG: Appbase = file:/// 
LOG: Initial PrivatePath = 
Calling assembly : Quartz, Version=2.6.0.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4. 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: d\web.config 
LOG: Using host configuration file: C:\Users\ \Documents\IISExpress\config\aspnet.config 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. 
LOG: Post-policy reference: Common.Logging, Version=3.3.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/f3308e15/e6cfbeeb/Common.Logging.DLL. 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/f3308e15/e6cfbeeb/Common.Logging/Common.Logging.DLL. 
LOG: Attempting download of new URL file:/// bin/Common.Logging.DLL. 
LOG: Attempting download of new URL file:// SCS.Presentation.Web/bin/Common.Logging/Common.Logging.DLL. 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/f3308e15/e6cfbeeb/Common.Logging.EXE. 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/f3308e15/e6cfbeeb/Common.Logging/Common.Logging.EXE. 
LOG: Attempting download of new URL file:/// /bin/Common.Logging.EXE. 
LOG: Attempting download of new URL file:/// SCS.Presentation.Web/bin/Common.Logging/Common.Logging.EXE. 

Le même code fonctionnait avant un certain temps, tout d'un coup, il a commencé à jeter cette exception. S'il vous plaît trouverez ci-dessous mon code,

var id = queryParams.Schedule.ScheduleId.ToString(); 
       var config = (NameValueCollection)ConfigurationManager.GetSection("quartz"); 
       // First we must get a reference to a scheduler 
       ISchedulerFactory sf = new StdSchedulerFactory(config); 
       IScheduler scheduler = sf.GetScheduler(); 

       ITrigger trigger; 
       IJobDetail job = JobBuilder.Create<ScheduleJob>() 
       .WithIdentity(id) 
       .Build(); 

Je reçois une erreur sur cette ligne

ISchedulerFactory sf = new StdSchedulerFactory(config); 
+0

Avez-vous fait référence à Quartz.net grâce à son paquetage nuget? – yorah

+0

Avez-vous 'Common.Logging' dans vos références de projet? – yorah

+0

Oui, j'ai référencé Quartz.net à travers son paquet nuget et j'ai Common.Logging dans vos références de projet. –

Répondre

0

Ceci est un problème commun à quartz. Vous devez ajouter une redirection de liaison à votre configuration pour Common.Logging et Common.Logging.Core. Ajoutez simplement ceci à votre config, que le quartz peut trouver les assemblages de notation.

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

Vous devez échanger le newVersion="3.4.1.0" à la version que vous avez installé pour les deux ensembles.