我在Quartz.net初始化StdSchedulerFactory时遇到错误
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.
相同的代码在一段时间之前工作,突然间它开始抛出这个异常。 请在下面找到我的代码,
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();
我在这一行收到错误
ISchedulerFactory sf = new StdSchedulerFactory(config);
答案 0 :(得分:1)
这是石英的常见问题。您需要为Common.Logging
和Common.Logging.Core
的配置添加绑定重定向。只需将其添加到您的配置中,石英就可以找到记录组件。
<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>
您需要将newVersion="3.4.1.0"
交换为您为两个程序集安装的版本。