Job throws - System.TypeLoadException

I need a help, I have used Hangfire(1.6.17) on .net core application for scheduling and recurring jobs…it works fine for 2 3 job en-queued but when it get more than 2 or 3 jobs at same time to be excute, some job gets failed and some goes in retry section and some of them gets success.

Exception
Failed
Can not change the state to ‘Enqueued’: target method was not found.

System.TypeLoadException

Could not load type ‘MyApp.Repository.AsyncScrumRepository.AsyncScrumRepository’ from assembly ‘MyApp.Repository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’.

System.TypeLoadException: Could not load type ‘MyApp.Repository.AsyncScrumRepository.AsyncScrumRepository’ from assembly ‘MyApp.Repository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’.
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type, ObjectHandleOnStack keepalive)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at Hangfire.Storage.InvocationData.Deserialize()

When I manually triggered that failed and retry section job via UI Dashboard, by 1 or 2 trigger, all job gets success. I am using this in production server and didn’t expect this kind of issue and now I have to trigger jobs in my production manually.

Need urgent help
Thanks In Advance

1 Like

Here is the screenshot of exception

I have searched out your git and blog discussion

And updated my application -

  • Having same version of Hangfire in every project of solution
  • Every dependent method to be called from Hangfire job are now public method
  • Having specific queue name for my jobs

This ansewear helped me in same situation https://stackoverflow.com/a/23591868/4745982