I am new to Hangfire and I am having an issue with the configuration. I have posted this question to StackExchange but I am not allowed to enter the link so copying the question here
I have installed Hangfire via ‘Manage NuGet Packages’ option in Visual Studio 2012. I am using SQL Server 2008 R2 for one project and SQL Server 2012 Enterprise for another project. My project is compatible with .Net 4.0 so I couldn’t download the latest Hangfire which is compatible with .Net4.5 so I downloaded Hangfire (.Net 4.0) via NuGet.
I added a new Startup file as required by Owin & Hangfire configuration. The file is as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Hangfire;
using Hangfire.SqlServer;
using Microsoft.Owin;
using Owin;
/// <summary>
/// Summary description for Startup
/// </summary>
///
[assembly: OwinStartup(typeof(MyProj.Startup))]
namespace MyProj
{
public class Startup
{
public Startup()
{
//
// TODO: Add constructor logic here
//
}
public void Configuration(IAppBuilder app)
{
app.UseHangfire(config =>
{
config.UseSqlServerStorage("ASP_NETConnectionString");
config.UseServer();
});
}
}
}
Hangfire installation automatically added following lines in the web.config:
<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.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
When I run the project, I receive following error on Line 29:
Could not load type 'Common.Logging.LogManager' from assembly 'Common.Logging.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Could not load type 'Common.Logging.LogManager' from assembly 'Common.Logging.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e'.
Source Error:
Line 27: app.UseHangfire(config =>
Line 28: {
Line 29: config.UseSqlServerStorage("ASP_NETConnectionString");
Line 30: config.UseServer();
Line 31: });
When I comment the dependent assembly for Common.Logging.Core in the web.config then I receive the following error on Line 30:
Could not load file or assembly 'Common.Logging.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Common.Logging.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
Line 28: {
Line 29: config.UseSqlServerStorage("ASP_NETConnectionString");
Line 30: config.UseServer();
Line 31: });
Line 32: }
There seems to be a configuration issue (incompatibility) with different versions of the Common.Logging.Core dll, please note I only have one file in the bin folder for Common.Logging.Core (V3.0.0.0), I tried to find V2.2.0.0 to check if this would resolve the ‘Could not load Common.Logging.LogManager’ but I couldn’t find this dll on the web, please advice.
Please note that the installation didn’t create HangFireConfig.cs file.
Thanks for reading and any help would be highly appreciated.