1

Resolved

AutoFac exception, IBackgroundService is Unregistered

description

Do we need to register IBackgroundService with AutoFac? This exception seems to occur every minute when the Sweep method is invoked.

Here are the exception details:

Exception Message:
The requested service 'Orchard.Tasks.IBackgroundService' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.

Stack Trace:
Autofac.dll!Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Line 349    C#
Autofac.dll!Autofac.ResolutionExtensions.Resolve(Autofac.IComponentContext context, System.Type serviceType, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Line 244 + 0x27 bytes   C#
Autofac.dll!Autofac.ResolutionExtensions.Resolve<Orchard.Tasks.IBackgroundService>(Autofac.IComponentContext context, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter> parameters) Line 197 + 0x49 bytes  C#
Autofac.dll!Autofac.ResolutionExtensions.Resolve<Orchard.Tasks.IBackgroundService>(Autofac.IComponentContext context) Line 181 + 0x34 bytes C#
Orchard.Framework.dll!Orchard.Environment.WorkContextImplementation.Resolve<Orchard.Tasks.IBackgroundService>() Line 19 + 0x3b bytes C#
Orchard.Framework.dll!Orchard.Environment.WorkContextAccessor.ThreadStaticScopeImplementation.Resolve<Orchard.Tasks.IBackgroundService>() Line 137 + 0x46 bytes C#
Orchard.Framework.dll!Orchard.Tasks.SweepGenerator.DoWork() Line 64 + 0x1b bytes    C#
Orchard.Framework.dll!Orchard.Tasks.SweepGenerator.Elapsed(object sender, System.Timers.ElapsedEventArgs e) Line 50 + 0x8 bytes C#
Assuming this is a valid bug, I am wondering how these kinds of errors might be avoided in future new releases. Does the development team test and develop with CLR Exceptions (thrown and checked) turned on? This would help catch uncaught exceptions that are otherwise masked by existing try/catch logic.

Thanks,
Shaun

comments

stonstad wrote Oct 21, 2013 at 10:00 PM

1.7.1

sebastienros wrote Oct 22, 2013 at 8:29 PM

Repro steps ?