Я установил Hangfire с помощью параметра «Управление пакетами NuGet» в Visual Studio 2012. Я использую SQL Server 2008 R2 для одного проекта и SQL Server 2012 Enterprise для другого проекта. Мой проект совместим с .Net 4.0, поэтому я не смог загрузить последнюю версию Hangfire, совместимую с .Net4.5, поэтому я загрузил Hangfire (.Net 4.0) через NuGet.
Я добавил новый файл запуска, как того требует конфигурация Owin & Hangfire. Файл выглядит следующим образом:
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 автоматически добавила следующие строки в 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>
Когда я запускаю проект, я получаю следующую ошибку в строке 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: });
Когда я комментирую зависимую сборку для Common.Logging.Core в файле web.config, я получаю следующую ошибку в строке 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: }
Кажется, есть проблема с конфигурацией (несовместимость) с разными версиями dll Common.Logging.Core, обратите внимание, что у меня есть только один файл в папке bin для Common.Logging.Core (V3.0.0.0), я пытался найдите V2.2.0.0, чтобы проверить, решит ли это проблему «Не удалось загрузить Common.Logging.LogManager», но я не смог найти эту dll в Интернете, пожалуйста, посоветуйте.
Обратите внимание, что при установке не был создан файл HangFireConfig.cs.
Спасибо за чтение, и любая помощь будет высоко оценена.