读取配置文件异常,配置系统未能初始化

异常原因:配置文件内容的顺序有一定要求

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=&quot;Data Source=.\sqlexpress;Initial Catalog=background;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

  <WebConfigSection WebName="占占网站" DoMain="www.zhanzhan.com"  />
  <appSettings>
    <add key="site" value="www.zzl.com"/>

  </appSettings>
</configuration>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python初始化配置文件通常是指在程序启动时读取配置文件,用于配置程序的基本参数和选项。常见的Python初始化配置文件有INI格式的配置文件和JSON格式的配置文件。 INI格式的配置文件通常由一系列节组成,每个节包含一系列键值对。例如: ``` [server] host = localhost port = 8080 [database] user = root password = 123456 ``` 这个配置文件包含了两个节,分别是server和database。server节包含了host和port两个键值对,而database节则包含了user和password两个键值对。 Python读取INI格式的配置文件可以使用标准库中的ConfigParser模块。例如,以下代码读取上面的配置文件: ``` import configparser config = configparser.ConfigParser() config.read('config.ini') host = config.get('server', 'host') port = config.getint('server', 'port') user = config.get('database', 'user') password = config.get('database', 'password') ``` JSON格式的配置文件则是一种类似于字典的结构,包含了一系列键值对。例如: ``` { "server": { "host": "localhost", "port": 8080 }, "database": { "user": "root", "password": "123456" } } ``` 这个配置文件包含了两个键,分别是server和database。server键包含了host和port两个子键,而database键则包含了user和password两个子键。 Python读取JSON格式的配置文件可以使用标准库中的json模块。例如,以下代码读取上面的配置文件: ``` import json with open('config.json') as f: config = json.load(f) host = config['server']['host'] port = config['server']['port'] user = config['database']['user'] password = config['database']['password'] ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值