{"record":{"id":"ab8f6579bf5c416c","repo":"HangfireIO/Hangfire","slug":"type-ab8f65","errorCode":null,"errorMessage":"type","messagePattern":"type","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/Obsolete/Job.Obsolete.cs","lineNumber":31,"sourceCode":"// You should have received a copy of the GNU Lesser General Public \n// 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)","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/Obsolete/Job.Obsolete.cs#L13-L49","documentation":"Thrown as ArgumentNullException by the obsolete Job(Type, MethodInfo, string[]) constructor when the 'type' argument is null. The constructor records the owning Type, MethodInfo, and pre-serialized arguments for a background job; a null type makes the job unidentifiable and is rejected at line 31.","triggerScenarios":"Calling 'new Job(null, method, arguments)' — i.e. constructing a Job with a null Type reference, often because the Type was resolved dynamically (e.g. Type.GetType returning null for an unqualified type name) and not null-checked before use.","commonSituations":"Reflective job construction where Type.GetType(\"Namespace.Type, Assembly\") returns null due to a missing assembly load or a typo in the fully-qualified name; serialization round-trips that reconstruct the Job from stored data with a null type field; test helpers that pass null placeholders.","solutions":["Use the non-obsolete Job(Type, MethodInfo, object[]) constructor overload instead of this string-arguments variant.","Null-check the Type before constructing the Job and log a clear error about which type failed to resolve.","Ensure the type is resolvable: load the assembly first, or use typeof()/an expression-based Job.FromExpression call that resolves the type at compile time."],"exampleFix":"// before\nvar type = Type.GetType(\"MyApp.Jobs, MyApp\"); // returns null if assembly not loaded\nvar job = new Job(type, method, arguments);\n\n// after\nvar job = Job.FromExpression<MyJobs>(x => x.DoWork(arg));","handlingStrategy":"validation","validationCode":"if (type == null) throw new ArgumentNullException(nameof(type));\nvar job = new Job(type, method, arguments);","typeGuard":"static bool IsResolvableType(string fullName) => Type.GetType(fullName) != null;","tryCatchPattern":null,"preventionTips":["Prefer Job.FromExpression<T>(...) which resolves the type at compile time.","When using Type.GetType, always null-check and load the assembly explicitly."],"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"}