3

This is my first time posting here.

I am currently writing an ASP.NET MVC application (using .NET 4.5.2 and MVC 5). I want to integrate Hangfire into my project. I have set up a side project which worked. But when I tried to integrate it into my main project, several errors occurred. They are:

  1. The .dll files had to be strong-named (I fixed this issue by using ildasm/ilasm to strong name them. I replace the original files that came with the nuget package.)

  2. After strong-naming and replacing the files, I ran into another error. When I tried to build and run the solution, a 'GlobalConfiguration' does not exists in the current context, and also a are you missing an assembly reference error is thrown.

I have tried various ways to solve this, but to no avail. I would really like some advice on this ! Thanks !

1 Answers1

1

GlobalConfiguration is a class in the Hangfire namespace. You should import the namespace so that you can use it (and the extension methods it provides)

using Hangfire;

So now code like this will work:

GlobalConfiguration.Configuration.UseSqlServerStorage("MyConnectionString");
DavidG
  • 113,891
  • 12
  • 217
  • 223
  • Interestingly, this does not work for me, see my question https://stackoverflow.com/questions/59736118/how-to-configure-hangfire-with-asp-net-to-obtain-connection-string-from-config-f/ – B--rian Jan 15 '20 at 09:19
  • 1
    The 2nd command of yours is underlined in red in my VisualStudio, and I suppose it is due a conflict with `System.Web.Http`. I am struggling to reference the full name space `Hangfire.GlobalConfiguration.[...]` or something. – B--rian Jan 15 '20 at 09:25