SEHException Error

I know this is not really directly a Hangfire issue/question, but I do need some help or ideas on this. Have some code that I’ve used for a while in my website, where we use a 3rd party DLL. Works well directly from the site. From within my hangfire job, starting with the 2nd time to use the method, I get the following error:

System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.

Is there something with the hangfire server that might need to be done different. My code has Dispose on the use of this 3rd party reference, but thought I’d post here for some ideas.

0x80004005 is a very generic error (E_FAIL), so it can be pretty much anything. Hard to tell without any details.

Could be different thread apartment state (might matter for some COM objects), or a different user account without activation permission for the specific COM object (if you’re impersonating requests in IIS, or running Hangfire server in a separate process), or a ton of other things…