Hangfire & Windows service : jobs still being process by webapp

Hello there,

Just starting using Hangfire with asp.net core 2.2.
Since running my jobs in the webapp make it lag a bit, I’m trying to queue the jobs with the app, and process them with a windows service.

Windows service is configured as mentioned in the doc and running well.
I commented the app.UseHangfireServer() in Startup.cs but still, jobs are being processed by the iis server of my webapp.

Did anyone encountered this before? Is there a way to resolve thios?

Thanks a lot :slight_smile:

@Jonathan_D You need to change the startup of your web app to no longer run the Hangfire Server. Typically, if you are using OWIN, you would have something like:
app.UseHangfireServer();
in your Startup class. Simply remove that line and you should be good.

Thanks for your time @tstone842, as I mentioned in the original post, I already removed that line.
Well, somehow, it seems that jobs are being passing through the service now, but i’m still stuck because jobs not being processed at all.

See the following error :

Could not load file or assembly ‘Cri.Interactif.GenerateurCodes.Web, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.Assembly.Load(AssemblyName assemblyRef) at Hangfire.Common.TypeHelper.AssemblyResolver(String assemblyString) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Hangfire.Common.TypeHelper.CachedAssemblyResolver(AssemblyName assemblyName) at System.TypeNameParser.ResolveAssembly(String asmName, Func2 assemblyResolver, Boolean throwOnError, StackCrawlMark& stackMark) at System.TypeNameParser.ConstructType(Func2 assemblyResolver, Func4 typeResolver, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark) at System.TypeNameParser.GetType(String typeName, Func2 assemblyResolver, Func4 typeResolver, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark) at System.Type.GetType(String typeName, Func2 assemblyResolver, Func`4 typeResolver, Boolean throwOnError) > at Hangfire.Common.TypeHelper.DefaultTypeResolver(String typeName) at Hangfire.Storage.InvocationData.DeserializeJob()

I assume that exception is coming from your Windows Service. Be sure that your windows service project has referencing to the any and ALL assemblies that are required for the background jobs you are queuing to Hangfire.