{"record":{"id":"fff45df0f50fe182","repo":"HangfireIO/Hangfire","slug":"activator","errorCode":null,"errorMessage":"activator","messagePattern":"activator","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/JobActivator.cs","lineNumber":76,"sourceCode":"        {\n#pragma warning disable 618\n            return BeginScope();\n#pragma warning restore 618\n        }\n\n        public virtual JobActivatorScope BeginScope(PerformContext context)\n        {\n            return this.BeginScope(new JobActivatorContext(context.Connection, context.BackgroundJob, context.CancellationToken));\n        }\n\n        class SimpleJobActivatorScope : JobActivatorScope\n        {\n            private readonly JobActivator _activator;\n            private readonly List<IDisposable> _disposables = new List<IDisposable>();\n\n            public SimpleJobActivatorScope([NotNull] JobActivator activator)\n            {\n                if (activator == null) throw new ArgumentNullException(nameof(activator));\n                _activator = activator;\n            }\n\n            public override object Resolve(Type type)\n            {\n                var instance = _activator.ActivateJob(type);\n                var disposable = instance as IDisposable;\n\n                if (disposable != null)\n                {\n                    _disposables.Add(disposable);\n                }\n\n                return instance;\n            }\n\n            public override void DisposeScope()\n            {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/JobActivator.cs#L58-L94","documentation":"Thrown by the SimpleJobActivatorScope constructor when the activator argument is null. This is a private nested class inside JobActivator used as the default scope; it stores the activator to resolve job instances on demand.","triggerScenarios":"Internally, when JobActivator.BeginScope() creates a SimpleJobActivatorScope(this) where 'this' is somehow null (which should not happen under normal conditions). This error indicates a corrupted or misuse of the activator hierarchy.","commonSituations":"A custom JobActivator subclass that incorrectly delegates to new SimpleJobActivatorScope(null), or reflection-based code that invokes the internal constructor with null. Extremely rare in production since the constructor is internal.","solutions":["If subclassing JobActivator and overriding BeginScope, pass a valid non-null activator (typically 'this')","Avoid using reflection to construct internal types with null arguments","Report as a Hangfire bug if it occurs without custom activator code"],"exampleFix":"// before (in a custom activator)\npublic override JobActivatorScope BeginScope(JobActivatorContext ctx)\n    => new SimpleJobActivatorScope(null);\n\n// after\npublic override JobActivatorScope BeginScope(JobActivatorContext ctx)\n    => new SimpleJobActivatorScope(this);","handlingStrategy":"validation","validationCode":"if (activator == null) throw new ArgumentNullException(nameof(activator));\nvar scope = new JobActivator.SimpleJobActivatorScope(activator); // internal - typically not called directly","typeGuard":"activator != null && activator is JobActivator","tryCatchPattern":null,"preventionTips":["When subclassing JobActivator, always pass 'this' to scope constructors","Avoid reflection-based instantiation of internal types","Report unexpected occurrences as potential Hangfire bugs"],"tags":["job-activator","null-argument","internal-api","hangfire"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}