{"record":{"id":"8c2312aabcd12475","repo":"aspnetboilerplate/aspnetboilerplate","slug":"must-set-localizationsourcename-before-in-order-t-8c2312","errorCode":null,"errorMessage":"Must set LocalizationSourceName before, in order to get LocalizationSource","messagePattern":"Must set LocalizationSourceName before, in order to get LocalizationSource","errorType":"exception","errorClass":"AbpException","httpStatus":null,"severity":"error","filePath":"src/Abp/BackgroundJobs/BackgroundJobBase.cs","lineNumber":65,"sourceCode":"        public ILocalizationManager LocalizationManager { protected get; set; }\n\n        /// <summary>\n        /// Gets/sets name of the localization source that is used in this application service.\n        /// It must be set in order to use <see cref=\"L(string)\"/> and <see cref=\"L(string,CultureInfo)\"/> methods.\n        /// </summary>\n        protected string LocalizationSourceName { get; set; }\n\n        /// <summary>\n        /// Gets localization source.\n        /// It's valid if <see cref=\"LocalizationSourceName\"/> is set.\n        /// </summary>\n        protected ILocalizationSource LocalizationSource\n        {\n            get\n            {\n                if (LocalizationSourceName == null)\n                {\n                    throw new AbpException(\n                        \"Must set LocalizationSourceName before, in order to get LocalizationSource\");\n                }\n\n                if (_localizationSource == null || _localizationSource.Name != LocalizationSourceName)\n                {\n                    _localizationSource = LocalizationManager.GetSource(LocalizationSourceName);\n                }\n\n                return _localizationSource;\n            }\n        }\n\n        private ILocalizationSource _localizationSource;\n\n        /// <summary>\n        /// Reference to the logger to write logs.\n        /// </summary>\n        public ILogger Logger { protected get; set; }","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/aspnetboilerplate/aspnetboilerplate/blob/2323c13a152aa0ebfb37af3830f687d7f5b53795/src/Abp/BackgroundJobs/BackgroundJobBase.cs#L47-L83","documentation":"BackgroundJobBase.LocalizationSource lazily resolves an ILocalizationSource from LocalizationSourceName and throws if that name is null. LocalizationSourceName is normally set via the [LocalizationSourceName] attribute or by overriding the property; without it the job cannot localize its display/log strings.","triggerScenarios":"Executing a background job class that neither has a LocalizationSourceName attribute nor overrides the LocalizationSourceName property, and whose code path touches LocalizationSource (e.g. via L(...)).","commonSituations":"Custom background job copied from a sample without the attribute; job class in an assembly ABP's convention-based localization doesn't associate with any source.","solutions":["Add [LocalizationSourceName(\"YourSourceName\")] to the job class","Or override 'protected override string LocalizationSourceName => AbpConsts.LocalizationSourceName;' (your source)","Or override the LocalizationSource property entirely to return a custom ILocalizationSource"],"exampleFix":"// before\npublic class EmailJob : BackgroundJob<EmailArgs> { /* no source name */ }\n// after\n[LocalizationSourceName(\"MyApp\")]\npublic class EmailJob : BackgroundJob<EmailArgs> { }","handlingStrategy":"validation","validationCode":"if (job.LocalizationSourceName == null)\n    throw new InvalidOperationException(\"Set [LocalizationSourceName] on the job class first\");","typeGuard":null,"tryCatchPattern":"try { text = job.L(\"Done\"); }\ncatch (AbpException ex) when (ex.Message.Contains(\"Must set LocalizationSourceName\"))\n{\n    text = \"Done\"; // fallback to raw key\n}","preventionTips":["Decorate every background job class with [LocalizationSourceName]","Keep the named source registered in your module's Configuration.Localization.Sources","Add an architecture test asserting all BackgroundJobBase subclasses define a source name"],"tags":["abp","background-jobs","localization","configuration"],"backgroundTag":"missing-required-config-field","analyzedSha":"2323c13a152aa0ebfb37af3830f687d7f5b53795","analyzedAt":"2026-09-08T08:00:50.638Z","contentChangedAt":"2026-09-08T08:00:50.638Z","schemaVersion":2},"datasetVersion":"2026-09-17T20:17:13.540Z"}