异常原因:配置文件内容的顺序有一定要求
configSections-->connectionStrings-->appSettings
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="WebConfigSection" type="MediaActionServer.WebConfigSection, MediaActionServer"/> </configSections> <connectionStrings> <add name="backgroundEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\sqlexpress;Initial Catalog=background;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" /> </connectionStrings> <WebConfigSection WebName="占占网站" DoMain="www.zhanzhan.com" /> <appSettings> <add key="site" value="www.zzl.com"/> </appSettings> </configuration>