Hangfire with .Net Core Console Application

dotnetcore
aspnetcore
Tags: #<Tag:0x00007f8bb8729e08> #<Tag:0x00007f8bb8729638>

#1

Hi,

Is there a way to run Hangfire with .Net Core Console Application? I tried below code like mentioned in documents " Processing jobs in a console application" section but i get "Could not load file or assembly “ConsoleAplication1"”. Could anyone help me about this? Or is it a bug?

    services.AddHangfire(config =>
            {
                var hangFireOption = new HangFireOptions();

                config.UseMongoStorage(
                    new MongoClient("mongo_connection_string"),
                    "database_name",
                    new MongoStorageOptions() { MigrationOptions = new MongoMigrationOptions() { Strategy = MongoMigrationStrategy.Migrate, BackupStrategy = MongoBackupStrategy.Collections } });
            });

            services.AddHangfireServer();

After this configuration, im using Hangfire Recurring job in a hostedService like below:

RecurringJob.AddOrUpdate("hangfire test console ", () => TestMethod(), Cron.Minutely);

Thanks.


#2

Did you look at the following article?