HangfireIO / HangfireIO/Hangfire
System.MissingMethodException: No parameterless constructor defined for this object.
- Dominant language
- C#
- Stars
- 10.1k
- Forks
- 1.8k
- Avg merge
- 1h 19m
- Merged PRs (30d)
- 1
Description
My jobs are running successfully but I get this error on all of them. I am using Autofac Activator.
GlobalConfiguration.Configuration.UseAutofacActivator(container); Here is what my constructor looks like for the job and it works but I do get an error.
private readonly ICacheClient _cache;
private readonly IOnBaseService _onBaseService;
private readonly ILogger _logger;
private readonly IDocumentCommands _documentCommands;
public OnBase(IDocumentCommands documentCommands, ILogger logger, IOnBaseService onBaseService, ICacheClient cache)
{
_documentCommands = documentCommands;
_logger = logger;
_onBaseService = onBaseService;
_cache = cache;
}
No parameterless constructor defined for this object.
System.MissingMethodException: No parameterless constructor defined for this object.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Hangfire.JobActivator.ActivateJob(Type jobType)
at Hangfire.JobActivator.SimpleJobActivatorScope.Resolve(Type type)
at Hangfire.Server.CoreBackgroundJobPerformer.Perform(PerformContext context)
at Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass8_0.b__0()
at Hangfire.Server.BackgroundJobPerformer.InvokePerformFilter(IServerFilter filter, PerformingContext preContext, Func`1 continuation)
at Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass8_1.b__2()
at Hangfire.Server.BackgroundJobPerformer.PerformJobWithFilters(PerformContext context, IEnumerable`1 filters)
at Hangfire.Server.BackgroundJobPerformer.Perform(PerformContext context)
at Hangfire.Server.Worker.PerformJob(BackgroundProcessContext context, IStorageConnection connection, String jobId)
Contributor guide
Research direction
Start with the Autofac activator configuration shown in the report and trace the stack from JobActivator.ActivateJob through SimpleJobActivatorScope.Resolve. Compare the configured activation path with the fallback path that calls Activator.CreateInstance; done means identifying why the registered activator is not being used and documenting or reproducing the required correction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100