# No parameterless constructor defined for this object after configuration for always running in IIS

**URL:** <https://discuss.hangfire.io/t/no-parameterless-constructor-defined-for-this-object-after-configuration-for-always-running-in-iis/7086>\
**Category:** question\
**Created:** [February 25, 2020, 7:43am UTC](https://discuss.hangfire.io/t/no-parameterless-constructor-defined-for-this-object-after-configuration-for-always-running-in-iis/7086 "2020-02-25T07:43:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![talsja](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/talsja/32/1986_2.png) [@talsja](https://discuss.hangfire.io/u/talsja)\
**Post date:** [February 25, 2020, 7:43am UTC](https://discuss.hangfire.io/t/no-parameterless-constructor-defined-for-this-object-after-configuration-for-always-running-in-iis/7086/1 "2020-02-25T07:43:04Z")

</div>

I have installed HangFire and also HangFire Autofac.  
All workes fine. I have no problems resolving dependancies and my enqueued jobs are fired without problems. Now i have a need to schedule a job in the night so i want to configure my IIS to always running. So i followed [http://docs.hangfire.io/en/latest/deployment-to-production/making-aspnet-app-always-running.html](http://docs.hangfire.io/en/latest/deployment-to-production/making-aspnet-app-always-running.html) and configured as so. When i now run an enqueued job i am getting an error:  
No parameterless constructor defined for this object

Has anyone an idea about this?

My Global.asax:  
protected void Application\_Start(object sender, EventArgs e)  
{  
AreaRegistration.RegisterAllAreas();  
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);  
RouteConfig.RegisterRoutes(RouteTable.Routes);  
BundleConfig.RegisterBundles(BundleTable.Bundles);

#if DEBUG  
BundleTable.EnableOptimizations = false;  
#else  
BundleTable.EnableOptimizations = true;  
#endif

```
        MvcHandler.DisableMvcResponseHeader = true;

        // Clears all previously registered view engines.
        ViewEngines.Engines.Clear();
        
        ViewEngines.Engines.Add(new RazorViewEngine());

        JsonConvert.DefaultSettings = () => new JsonSerializerSettings
        {
            Formatting = Formatting.Indented,
            ReferenceLoopHandling = ReferenceLoopHandling.Ignore
        };
    
        HangfireBootstrapper.Instance.Start();
    }

    protected void Application_End(object sender, EventArgs e)
    {
        HangfireBootstrapper.Instance.Stop();
    }

```

My StartUp.cs  
public partial class Startup  
{  
public void Configuration(IAppBuilder app)  
{  
// Configure dependancies  
Bootstrapper.SetAutofacContainer(app);

```
        // Configure authentication
        ConfigureAuth(app);

        // Configure Hangfire
        var dashboardOptions = new DashboardOptions { Authorization = new[] { new HangfireAuthorizationFilter() } };
        app.UseHangfireDashboard("/hangfire", dashboardOptions);        
    }
}

```

Here is my Autofac configuration:  
public class Bootstrapper  
{  
public static void SetAutofacContainer(IAppBuilder app)  
{  
var builder = new ContainerBuilder();

```
        builder.RegisterControllers(Assembly.GetExecutingAssembly());
        builder.RegisterModule<AutofacWebTypesModule>();
        builder.RegisterFilterProvider();

        builder.Register(c => new HttpContextWrapper(HttpContext.Current)).As<HttpContextBase>().InstancePerLifetimeScope();

        builder.RegisterType<DataContextFactory>().As<IDataContextFactory>().InstancePerLifetimeScope();
        builder.RegisterType(typeof(EDMSContext)).As(typeof(DbContext)).InstancePerLifetimeScope();
        builder.RegisterType<EDMSContext>().AsSelf().InstancePerLifetimeScope();

        builder.RegisterModule(new IdentityModule());
        builder.RegisterModule<AutofacModule>();

        // Automapper
        var autoMapperConfig = new MapperConfiguration(cfg =>
        {
            cfg.AddProfile(new ReportingAutoMapperProfile());
            cfg.AddProfile(new WebAutoMapperProfile());
        });
        builder.Register(ctx => autoMapperConfig.CreateMapper()).SingleInstance();
        builder.RegisterModule<AutofacModule>();

        var container = builder.Build();
        GlobalConfiguration.Configuration.UseAutofacActivator(container);
        DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
    }
}
```

---

<div class="post-metadata">

**Author:** ![talsja](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/talsja/32/1986_2.png) [@talsja](https://discuss.hangfire.io/u/talsja)\
**Post date:** [February 25, 2020, 12:53pm UTC](https://discuss.hangfire.io/t/no-parameterless-constructor-defined-for-this-object-after-configuration-for-always-running-in-iis/7086/3 "2020-02-25T12:53:29Z")

</div>

Ohh i thought it worked but it seems not to work.  
Pffffff. So again, i have no clue

---

<div class="post-metadata">

**Author:** ![benmchap](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@benmchap](https://discuss.hangfire.io/u/benmchap)\
**Post date:** [February 27, 2020, 10:55am UTC](https://discuss.hangfire.io/t/no-parameterless-constructor-defined-for-this-object-after-configuration-for-always-running-in-iis/7086/4 "2020-02-27T10:55:26Z")

</div>

I’ve done pretty much the same thing and have the same problem.
