{"record":{"id":"fea01c653f7b1c67","repo":"JeffreySu/WeiXinMPSDK","slug":"section-sectionname-is-not-found","errorCode":null,"errorMessage":"Section {sectionName} is not found.","messagePattern":"Section (.+?) is not found\\.","errorType":"exception","errorClass":"ConfigurationErrorsException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Redis/ServiceStack.Redis/RedisConfigInfo.cs","lineNumber":34,"sourceCode":"        /// 获取配置信息，默认配置节点名称为RedisConfig\n        /// </summary>\n        /// <returns></returns>\n        public static RedisConfigInfo GetConfig()\n        {\n            RedisConfigInfo section = (RedisConfigInfo)ConfigurationManager.GetSection(\"RedisConfig\");\n            return section;\n        }\n\n        /// <summary>\n        /// 获取配置信息\n        /// </summary>\n        /// <param name=\"sectionName\">配置节点的sectionName</param>\n        /// <returns></returns>\n        public static RedisConfigInfo GetConfig(string sectionName)\n        {\n            RedisConfigInfo section = (RedisConfigInfo)ConfigurationManager.GetSection(sectionName);\n            if (section == null)\n                throw new ConfigurationErrorsException(\"Section \" + sectionName + \" is not found.\");\n            return section;\n        }\n        /// <summary>\n        /// 可写的Redis链接地址\n        /// </summary>\n        [ConfigurationProperty(\"WriteServerList\", IsRequired = false)]\n        public string WriteServerList\n        {\n            get\n            {\n                return (string)base[\"WriteServerList\"];\n            }\n            set\n            {\n                base[\"WriteServerList\"] = value;\n            }\n        }\n","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Redis/ServiceStack.Redis/RedisConfigInfo.cs#L16-L52","documentation":"RedisConfigInfo.GetConfig reads a custom configuration section (RedisConfigInfo) from app.config/web.config via ConfigurationManager.GetSection. If the section name does not resolve to a configured section it throws ConfigurationErrorsException. The library requires the Redis cache section to be declared with the correct type in the configSections block.","triggerScenarios":"Calling RedisConfigInfo.GetConfig(\"sectionName\") where the .config file lacks a <section name=\"sectionName\" type=\"Senparc.Weixin.Cache.Redis...RedisConfigInfo\"> registration, or the section element itself is absent, or the name is misspelled.","commonSituations":"Deploying to a new server without copying the config section, renaming the section in code but not in config, missing the configSections declaration, running a project that uses the Redis cache without adding its configuration.","solutions":["Add the <configSections><section name=\"...\" type=\"...RedisConfigInfo, Senparc.Weixin.Cache.Redis\"/> declaration and the section XML with WriteServerList/ReadServerList etc.","Verify the sectionName string passed to GetConfig matches the config exactly (case and spelling)","Ensure the correct app.config/web.config is deployed to the runtime output directory","If using ConfigHelper instead, call Senparc.Weixin.ConfigHelper.RegisterConfigFile or rely on auto registration so the section is created"],"exampleFix":"<!-- before: no section declared -->\n<!-- after -->\n<configSections>\n  <section name=\"Senparc.RedisConfig\" type=\"Senparc.Weixin.Cache.Redis.ServiceStack.Redis.RedisConfigInfo, Senparc.Weixin.Cache.Redis\" requirePermission=\"false\"/>\n</configSections>\n<Senparc.RedisConfig WriteServerList=\"...\" ReadServerList=\"...\" MaxReadPoolSize=\"\" MaxWritePoolSize=\"\" AutoStart=\"true\" LocalCacheTime=\"\" RecordeLog=\"false\"/>","handlingStrategy":"validation","validationCode":"var section = ConfigurationManager.GetSection(\"Senparc.RedisConfig\") as RedisConfigInfo;\nif (section == null) throw new InvalidOperationException(\"Add <configSections><section name=... type=...RedisConfigInfo...> and the section XML to your .config\");","typeGuard":null,"tryCatchPattern":"try { var cfg = RedisConfigInfo.GetConfig(\"Senparc.RedisConfig\"); }\ncatch (ConfigurationErrorsException ex) { log.Error(\"Redis config section missing: \" + ex.Message); throw new InvalidOperationException(\"Register the Redis config section in app.config/web.config\", ex); }","preventionTips":["Always declare both the <configSections> entry and the section XML","Copy config sections when deploying to new servers","Keep section name constants in one shared place to avoid typos"],"tags":["configuration","redis","config-section","dotnet"],"backgroundTag":"missing-config-section","analyzedSha":"be573f6f94bdbf718dd5f6cdecb137fbc7ff651e","analyzedAt":"2026-09-12T10:01:50.733Z","contentChangedAt":"2026-09-12T10:01:50.733Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}