{"record":{"id":"684b8046d01279bf","repo":"HangfireIO/Hangfire","slug":"could-not-find-connection-string-with-name-nameo","errorCode":null,"errorMessage":"Could not find connection string with name '{nameOrConnectionString}' in application config file","messagePattern":"Could not find connection string with name '(.+?)' in application config file","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.SqlServer/SqlServerStorage.cs","lineNumber":541,"sourceCode":"        {\n            var defaultQueueProvider = _options.DefaultQueueProvider ?? new SqlServerJobQueueProvider(this, _options);\n            QueueProviders = new PersistentJobQueueProviderCollection(defaultQueueProvider);\n        }\n\n        private static string GetConnectionString(string nameOrConnectionString)\n        {\n#if FEATURE_CONFIGURATIONMANAGER\n            if (IsConnectionString(nameOrConnectionString))\n            {\n                return nameOrConnectionString;\n            }\n\n            if (IsConnectionStringInConfiguration(nameOrConnectionString))\n            {\n                return ConfigurationManager.ConnectionStrings[nameOrConnectionString].ConnectionString;\n            }\n\n            throw new ArgumentException(\n                $\"Could not find connection string with name '{nameOrConnectionString}' in application config file\");\n#else\n            return nameOrConnectionString;\n#endif\n        }\n\n#if FEATURE_CONFIGURATIONMANAGER\n        private static bool IsConnectionString(string nameOrConnectionString)\n        {\n            return nameOrConnectionString.Contains(\";\");\n        }\n\n        private static bool IsConnectionStringInConfiguration(string connectionStringName)\n        {\n            var connectionStringSetting = ConfigurationManager.ConnectionStrings[connectionStringName];\n\n            return connectionStringSetting != null;\n        }","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.SqlServer/SqlServerStorage.cs#L523-L559","documentation":"Hangfire could not resolve the provided nameOrConnectionString value into a usable connection string. The value contained no semicolon (so it was not a raw connection string) and was not found in the application's connectionStrings configuration section. This code path only runs under the FEATURE_CONFIGURATIONMANAGER build target (full .NET Framework).","triggerScenarios":"Passing a connection-string name to the SqlServerStorage constructor or UseSqlServerStorage extension when that name is absent from <connectionStrings> in app.config/web.config; typo in the name; config file not deployed to the runtime directory.","commonSituations":"Mistyping the connection string name; app.config transformed incorrectly during publish; using a name from a different environment's config; deploying without the connectionStrings section; passing a partial connection string without a semicolon.","solutions":["Verify the exact name exists in the <connectionStrings> section of your app.config/web.config and matches what you pass to UseSqlServerStorage.","Alternatively, pass the full connection string (containing a semicolon) directly instead of a name.","Confirm the config file is present and copied to the output directory (Copy to Output Directory = Copy if newer)."],"exampleFix":"// before — name 'HangfireDB' not in config\nconfig.UseSqlServerStorage(\"HangfireDB\");\n// after — add to app.config\n//   <connectionStrings>\n//     <add name=\"HangfireDB\" connectionString=\"Server=.;Database=Hangfire;Integrated Security=true\" providerName=\"System.Data.SqlClient\" />\n//   </connectionStrings>\nconfig.UseSqlServerStorage(\"HangfireDB\");\n// or pass the full connection string directly:\nconfig.UseSqlServerStorage(\"Server=.;Database=Hangfire;Integrated Security=true\");","handlingStrategy":"validation","validationCode":"string nameOrConnectionString = /* from config */;\n\nbool isRawConnectionString = nameOrConnectionString.Contains(\";\");\nbool isInConfig = ConfigurationManager.ConnectionStrings[nameOrConnectionString] != null;\n\nif (!isRawConnectionString && !isInConfig)\n    throw new InvalidOperationException($\"Connection string '{nameOrConnectionString}' not found in config and is not a raw connection string.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the connection string name exists in <connectionStrings> before passing it to UseSqlServerStorage.","Prefer passing the full connection string (with semicolons) directly to avoid config-resolution ambiguity.","Ensure app.config/web.config is deployed alongside the application binary."],"tags":["connection-string","configuration","net-framework","config"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}