# Hangfire with .net core framework 4.6

**URL:** <https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270>\
**Category:** question\
**Tags:** dotnetcore\
**Created:** [August 2, 2016, 8:09am UTC](https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270 "2016-08-02T08:09:45Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicegirl](https://avatars.discourse-cdn.com/v4/letter/n/cab0a1/32.png) [@nicegirl](https://discuss.hangfire.io/u/nicegirl)\
**Post date:** [August 2, 2016, 8:09am UTC](https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270/1 "2016-08-02T08:09:45Z")

</div>

Hello,

I’am using Hangfire with [Asp.net](http://Asp.net) framework project 4.6, I get this error ;  
‘IServiceCollection’ does not contain a definition for ‘AddHangfire’ and no extension method ‘AddHangfire’ accepting a first argument of type ‘IServiceCollection’ could be found (are you missing a using directive or an assembly reference?)

‘IApplicationBuilder’ does not contain a definition for ‘UseHangfireServer’ and the best extension method overload ‘AppBuilderExtensions.UseHangfireServer(IAppBuilder)’ requires a receiver of type ‘IAppBuilder’ SMCModule.API…NET Framework 4.6 E:\MVC 6\SMCModule Solution\SMCModule\src\SMCModule.API\Startup.cs

Severity Code Description Project File Line Suppression State  
Error CS1929 ‘IApplicationBuilder’ does not contain a definition for ‘UseHangfireDashboard’ and the best extension method overload ‘AppBuilderExtensions.UseHangfireDashboard(IAppBuilder)’ requires a receiver of type ‘IAppBuilder’ SMCModule.API…NET Framework 4.6

SMCModule.API is the name of my project.

my project.json file is :  
{  
“dependencies”: {  
“Microsoft.ApplicationInsights.AspNetCore”: “1.0.0”,  
“Microsoft.AspNetCore.Mvc”: “1.0.0”,  
“Microsoft.AspNetCore.Server.IISIntegration”: “1.0.0”,  
“Microsoft.AspNetCore.Server.Kestrel”: “1.0.0”,  
“Microsoft.Extensions.Configuration.EnvironmentVariables”: “1.0.0”,  
“Microsoft.Extensions.Configuration.FileExtensions”: “1.0.0”,  
“Microsoft.Extensions.Configuration.Json”: “1.0.0”,  
“Microsoft.Extensions.Logging”: “1.0.0”,  
“Microsoft.Extensions.Logging.Console”: “1.0.0”,  
“Microsoft.Extensions.Logging.Debug”: “1.0.0”,  
“Microsoft.Extensions.Options.ConfigurationExtensions”: “1.0.0”,  
“SMCModule.Core”: “1.0.0-\*”,  
“Newtonsoft.Json”: “9.0.1”,  
“SimpleInjector”: “3.2.0”,  
“Microsoft.AspNetCore.Owin”: “1.0.0”,  
“Hangfire”: “1.6.0”  
},

“tools”: {  
“Microsoft.AspNetCore.Server.IISIntegration.Tools”: “1.0.0-preview2-final”  
},

“frameworks”: {  
“net46”: { }  
},

“buildOptions”: {  
“emitEntryPoint”: true,  
“preserveCompilationContext”: true  
},

“publishOptions”: {  
“include”: [  
“wwwroot”,  
“Views”,  
“Areas/\*\*/Views”,  
“appsettings.json”,  
“web.config”  
]  
},

“scripts”: {  
“postpublish”: [“dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%”]  
}  
}

Thanks.

---

<div class="post-metadata">

**Author:** ![odinserj](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/odinserj/32/648_2.png) [@odinserj](https://discuss.hangfire.io/u/odinserj)\
**Post date:** [August 4, 2016, 11:56am UTC](https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270/2 "2016-08-04T11:56:10Z")

</div>

Have you included the `using Hangfire;` statement?

---

<div class="post-metadata">

**Author:** ![gmatv](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@gmatv](https://discuss.hangfire.io/u/gmatv)\
**Post date:** [August 15, 2016, 1:54pm UTC](https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270/3 "2016-08-15T13:54:39Z")

</div>

I experience almost the same problem. Steps to reproduce in VS 2015:

1. File -\> New -\> Project
2. Choose "[ASP.Net](http://ASP.Net) Core Web Application (.Net Framework)
3. Select “Empty” template
4. In Package Management Console: “Install-Package Hangfire”
5. In Startup.cs, add:

using Hangfire;

```
    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        loggerFactory.AddConsole();

        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

       app.UseHangfireServer(); // ---> Expects IAppBuilder but there is IApplicationBuilder 

        app.Run(async (context) =>
        {
            await context.Response.WriteAsync("Hello World!");
        });
    }

```

Compiler Output:

Error CS1929 ‘IApplicationBuilder’ does not contain a definition for ‘UseHangfireServer’ and the best extension method overload ‘AppBuilderExtensions.UseHangfireServer(IAppBuilder)’ requires a receiver of type ‘IAppBuilder’

Thank you.

---

<div class="post-metadata">

**Author:** ![CrazyPyro](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@CrazyPyro](https://discuss.hangfire.io/u/CrazyPyro)\
**Post date:** [August 16, 2016, 4:54am UTC](https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270/4 "2016-08-16T04:54:00Z")

</div>

But what does your ConfigureServices method look like?  
Do you have a services.AddHangfire(…); call in it?  
Also, do you have either “Hangfire”: “1.6.0” or “Hangfire”: “1.6.\*” in your project.json?  
That IAppBuilder bit is suspicious - like it’s using an older version not designed to run in the latest .NET  
Are you also using the “net46” framework? What about targeting “netcoreapp1.0” instead?

---

<div class="post-metadata">

**Author:** ![gmatv](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@gmatv](https://discuss.hangfire.io/u/gmatv)\
**Post date:** [August 16, 2016, 6:14am UTC](https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270/5 "2016-08-16T06:14:32Z")

</div>

There is no ConfigureServices because it’s it’s a simplest project type. But I tried to add services.AddHangfire(…) and result is same - compile error.

Here is project.json.

```auto
{
  "dependencies": {
    "Hangfire": "1.6.2",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "net461": { }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": ["dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"]
  }
}

```

There are three possibility to create web application:

1. [ASP.NET](http://ASP.NET) Web Application (.Net Framework):  
UseHangfireServer is an extension to IAppBuilder, No problem to configure Hangfire
2. [ASP.NET](http://ASP.NET) Core Web Application (.Net Core):  
UseHangfireServer is an extension to IApplicationBuilder, No problem to configure Hangfire
3. [ASP.NET](http://ASP.NET) Core Web Application (.Net Framework):  
UseHangfireServer is an extension to IAppBuilder, but there is IApplicationBuilder only and it is not in the same assembly as in p.2  
In this case the project doesn’t compile

---

<div class="post-metadata">

**Author:** ![gmatv](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@gmatv](https://discuss.hangfire.io/u/gmatv)\
**Post date:** [August 16, 2016, 1:15pm UTC](https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270/6 "2016-08-16T13:15:53Z")

</div>

My colleague advised to install package Hangfire.AspNetCore instead of Hangfire and it started to work for “[ASP.NET](http://ASP.NET) Core Web Application (.Net Framework)”

---

<div class="post-metadata">

**Author:** ![saad749](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@saad749](https://discuss.hangfire.io/u/saad749)\
**Post date:** [August 24, 2016, 8:19am UTC](https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270/7 "2016-08-24T08:19:13Z")

</div>

I am having problem installing hangfire on [asp.net](http://asp.net) core project with .net framework 4.6.1.  
Hangfire.ASPNetCore tries to install Hangfire.Core which tries to install Owin which is not resolved. Can any body guide me what I am doing wrong here?  
gmatv, can u share your final solution?  
This is my project.json

```
{
  "dependencies": {
    "Hangfire.AspNetCore": "1.6.3",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": {
      "version": "1.0.0",
      "type": "build"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    }
  },

  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "frameworks": {
    "net461": { }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "Areas/**/Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": ["npm install", "bower install", "gulp clean", "gulp min"],
    "postpublish": ["dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"]
  }
}
```

---

<div class="post-metadata">

**Author:** ![plaisted](https://avatars.discourse-cdn.com/v4/letter/p/4491bb/32.png) [@plaisted](https://discuss.hangfire.io/u/plaisted)\
**Post date:** [August 24, 2016, 2:09pm UTC](https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270/8 "2016-08-24T14:09:54Z")

</div>

I running on net461 with aspcore without issues. I have:

```
"Hangfire": "1.6.2",
"Hangfire.AspNetCore": "1.6.2",

```

In my dependencies. In startup.cs I then added:

using Hangfire;

and under ConfigureServices:

```
        services.AddHangfire(configuration => {
            configuration.UseSqlServerStorage(Configuration.GetConnectionString("Hangfire"));
        });

```

and under Configure:

```
        app.UseHangfireDashboard();
        app.UseHangfireServer();

```

Is that not working for you?

---

<div class="post-metadata">

**Author:** ![saad749](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@saad749](https://discuss.hangfire.io/u/saad749)\
**Post date:** [August 25, 2016, 4:41am UTC](https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270/9 "2016-08-25T04:41:37Z")

</div>

Okay. This is little strange. I am not sure why it happened. With the project.json that I mentioned earlier, I was getting an issue with the OWIN restore As a dependency of Hangfire.Core. I didn’t try to explicitly load it on my work pc and for the whole day, I wasnt able to make it work.

If I changed my app to target netcoreapp1.0, Hangfire.AspNetCore use to work fine but I have some dependencies on the full framework and cant use it.

When I tried to restore the packages, at home pc, the Hangfire.AspNetCore restored fine with the OWIN dependency resolved.

I suspect, it has something to do with my Nuget Configurations maybe & Not with hangfire. I had messed around with them earlier.

---

<div class="post-metadata">

**Author:** ![plaisted](https://avatars.discourse-cdn.com/v4/letter/p/4491bb/32.png) [@plaisted](https://discuss.hangfire.io/u/plaisted)\
**Post date:** [August 25, 2016, 5:26pm UTC](https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270/10 "2016-08-25T17:26:02Z")

</div>

Are you using Visual Studio? I’ve noticed VS/Nuget occasionally get confused with netcore projects. Running “dotnet restore” from the command line seems to resolve everything for me.

---

<div class="post-metadata">

**Author:** ![joshit](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@joshit](https://discuss.hangfire.io/u/joshit)\
**Post date:** [March 27, 2017, 7:52am UTC](https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270/11 "2017-03-27T07:52:16Z")

</div>

What about this issue? I have the same problem and want to know, if there is a solution until now?

I am using [ASP.NET](http://ASP.NET) Core WebApplication (.NET Framework) and I need to use this project-type instead of [ASP.NET](http://ASP.NET) Core WebApplication (.NET Core), where Hangfire is working as expected.

---

<div class="post-metadata">

**Author:** ![Pmatua](https://avatars.discourse-cdn.com/v4/letter/p/58f4c7/32.png) [@Pmatua](https://discuss.hangfire.io/u/Pmatua)\
**Post date:** [January 29, 2018, 2:15pm UTC](https://discuss.hangfire.io/t/hangfire-with-net-core-framework-4-6/2270/12 "2018-01-29T14:15:30Z")

</div>

I just experienced the same problem when I installed NUGET package Hangfire.

Actually what I found that there are 2 projects AspNetCore and aspNetcore.NEtStandard

I didn’t investigate deep inside by It is looks like when you download from Nuget to [asp.net](http://asp.net) core (net461) VS load wrong references.  
Because AddHangfire() is just extension method of static class HangfireServiceCollectionExtensions which is located at Hangfire namespace. So if you load HangFire.AspNetCore, normally your VS should see this extension method.

So to do this work, I download one by one:

1. Hangfire.AspNetCore
2. HandFire.Core  
3)HangFire.SQLServer

Currently I’m using 1.6.17 version for all of them. And it is work perfectly.
