{"record":{"id":"47a46bc6433b3065","repo":"HangfireIO/Hangfire","slug":"method","errorCode":null,"errorMessage":"method","messagePattern":"method","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/Obsolete/Job.Obsolete.cs","lineNumber":32,"sourceCode":"// License along with Hangfire. If not, see <http://www.gnu.org/licenses/>.\n\nusing System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing Hangfire.Annotations;\nusing Hangfire.Server;\nusing Hangfire.Storage;\n\n// ReSharper disable once CheckNamespace\nnamespace Hangfire.Common\n{\n    partial class Job\n    {\n        [Obsolete(\"Please use Job(Type, MethodInfo, object[]) ctor overload instead. Will be removed in 2.0.0.\")]\n        public Job([NotNull] Type type, [NotNull] MethodInfo method, [NotNull] string[] arguments)\n        {\n            if (type == null) throw new ArgumentNullException(nameof(type));\n            if (method == null) throw new ArgumentNullException(nameof(method));\n            if (arguments == null) throw new ArgumentNullException(nameof(arguments));\n\n            Validate(type, nameof(type), method, nameof(method), arguments.Length, nameof(arguments));\n\n            Type = type;\n            Method = method;\n            Args = InvocationData.DeserializeArguments(method, arguments);\n        }\n\n        /// <exclude />\n        [NotNull]\n        [Obsolete(\"Please use `Args` property instead to avoid unnecessary serializations/deserializations. Will be deleted in 2.0.0.\")]\n        public string[] Arguments => InvocationData.SerializeArguments(Method, Args);\n\n        /// <exclude />\n        [Obsolete(\"This method is deprecated. Please use `CoreBackgroundJobPerformer` or `BackgroundJobPerformer` classes instead. Will be removed in 2.0.0.\")]\n        public object Perform(JobActivator activator, IJobCancellationToken cancellationToken)\n        {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/Obsolete/Job.Obsolete.cs#L14-L50","documentation":"Thrown as ArgumentNullException by the obsolete Job(Type, MethodInfo, string[]) constructor when the 'method' MethodInfo argument is null. The method is required both for Validate() (which checks accessibility, generic parameters, and signature) and for later invocation; a null method makes the job un-executable.","triggerScenarios":"Calling 'new Job(type, null, arguments)' — e.g. the MethodInfo was obtained via reflection (GetMethod) that returned null because the method name was misspelled, the binding flags were too restrictive, or the method is overloaded without disambiguation.","commonSituations":"Reflective job construction where type.GetMethod(\"DoWork\") returns null (no such method, or ambiguous overload); obfuscation/proguard-style renaming that changes the method name at runtime; dynamic code that builds jobs from configuration and passes a null method on misconfiguration.","solutions":["Use the non-obsolete Job(Type, MethodInfo, object[]) overload or, better, Job.FromExpression(...) to capture the method safely at compile time.","Null-check the MethodInfo returned by GetMethod and handle the not-found case explicitly before constructing the Job.","When using GetMethod on an overloaded method, use the overload that accepts parameter Type[] to disambiguate."],"exampleFix":"// before\nvar method = type.GetMethod(\"Run\"); // null if not found\nvar job = new Job(type, method, arguments);\n\n// after\nvar job = Job.FromExpression<MyJob>(x => x.Run(\"arg\"));","handlingStrategy":"validation","validationCode":"if (method == null) throw new ArgumentNullException(nameof(method));\nvar job = new Job(type, method, arguments);","typeGuard":"static MethodInfo SafeGetMethod(Type t, string name, Type[] args) => t.GetMethod(name, args);","tryCatchPattern":null,"preventionTips":["Prefer Job.FromExpression<T>(...) to capture MethodInfo safely.","When using GetMethod, disambiguate overloads with parameter Type[] and null-check the result."],"tags":["argument-null","job-construction","reflection","obsolete"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}