项目配置文件app.config/configuration/configSections

C#将可调整数据写在配置文件 应用程序配置文件(App.config)是标准的 XML 文件,XML 标记和属性是区分大小写的。它是可以按需要更改的,开发人员可以使用配置文件来更改设置,而不必重编译应用程序。 读取配置文件:  System.Configuration.ConfigurationManager.AppSettings["IP"]; 需要引用System 阅读详情
<configuration>//根节点
  <configSections> //配置节声明区域 
    <section name="MySection" type="System.Configuration.DictionarySectionHandler"/>//配置节声明(无父组声明)
    <sectionGroup name="MySectionGroup">//定义配置节组
      <section name="MyFirstSection" type="System.Configuration.SingleTagSectionHandler"/>//配置节组中的配置节声明1
      <section name="MySecondSection" type="System.Configuration.NameValueSectionHandler"/>//配置节组中的配置节声明2
    </sectionGroup>
  </configSections>
  //配置节设置区域开始
  <MySectionGroup>
    <MyFirstSection MyFirstSection="First"/>
    <MySecondSection>
      <add key="Second" value="Second Section"/>
    </MySecondSection>
  </MySectionGroup>
  <MySection>
    <add key="Top" value="Top Section"/>
  </MySection>
<pre name="code" class="html">  //配置节设置区域结束
 </configuration>
 



   配置节按类型分系统默认声明(存储键值对)和自定义配置

一:系统默认

          1.1.声明

             系统默认声明类型包括三种:

             ①:System.Configuration.SingleTagSectionHandler   (自定义配置设置键值属性,返回 System.Collections.Hashtable类型参数)

             ②:System.Configuration.DictionarySectionHandler   (返回 System.Collections.Hashtable类型数据)

             ③:System.Configuration.NameValueSectionHandler   (返回 System.Configuration.ReadOnlyNameValueCollection类型数据)

           1.2.使用

              ①:System.Configuration.SingleTagSectionHandler                

ConfigurationSettings.GetConfig("MySectionGroup/MyFirstSection")["MyFirstSection"];//如果存在分组则参数字符串格式为   “分组名/节点名”

              ②:System.Configuration.DictionarySectionHandler

ConfigurationManager.GetSection("MySection")["Top"];//如果存在分组则参数字符串格式为   “分组名/节点名”
              ③:System.Configuration.NameValueSectionHandler
((NameValueCollection)ConfigurationManager.GetSection(“MySectionGroup/MySecondSection”)).AllKeys[0];//如果存在分组则参数字符串格式为   “分组名/节点名”

           上述系统默认的配置可以用<appSettings>实现

二:自定义

           自定义配置我知道有两种:继承ConfigurationSection和实现IConfigurationSectionHandler接口。

          2.1.继承ConfigurationSection

 public class CustomSection : System.Configuration.ConfigurationSection
    {
        [ConfigurationProperty("sectionId", IsRequired = true, IsKey = true)]
        public int SectionId
        {
            get { return (int)base["sectionId"]; }
            set { base["sectionId"] = value; }
        }

        [ConfigurationProperty("sectionValue", IsRequired = false)]
        public string SectionValue
        {
            get { return base["sectionValue"].ToString(); }
            set { base["sectionValue"] = value; }
        }
    }

             操作此Section,我们将其动态加入app.config中,并读出来:
    public class CustomSectionBroker
    {
        private CustomSection customSection = null;
        public void InsertCustomSection()
        {
            customSection = new CustomSection();
            customSection.SectionId = 1;
            customSection.SectionValue = "The First Value";
            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            config.Sections.Add("CustomSection", customSection);
            config.Save(ConfigurationSaveMode.Minimal);
        }

        public int GetCustomSectionID()
        {
            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            CustomSection cs = config.GetSection("CustomSection") as CustomSection;
            return cs.SectionId;
        }
    }

        public void TestCustomSection()
        {
            CustomSectionBroker cb = new CustomSectionBroker();
            cb.InsertCustomSection();
            Assert.AreEqual(1, cb.GetCustomSectionID());
        }

              可以看下现在app.config文件的变化:

             

<configuration>
  <configSections>
    <section name="CustomSection" type="Tonnie.Configuration.Library.CustomSection, Tonnie.Configuration.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    <sectionGroup name="MySectionGroup">
      <section name="MyFirstSection" type="System.Configuration.DictionarySectionHandler"/>
      <section name="MySecondSection" type="System.Configuration.DictionarySectionHandler"/>
    </sectionGroup>
  </configSections>
  <CustomSection sectionId="1" sectionValue="The First Value" />
  <MySectionGroup>
    <MyFirstSection>
      <add key="First" value="First Section"/>
    </MyFirstSection>
    <MySecondSection>
      <add key="Second" value="Second Section"/>
    </MySecondSection>
  </MySectionGroup>
</configuration>
           增加了一个单独的Section,名为"CustomSection",并且包含了我们创建的2个 configurationProperty。我们还可以继续作扩展,现在我们的config中section的部分呈现的是<CustomSection sectionId="1" sectionValue="The First Value" /> ,

   这样 对于复杂的配置信息仍然不方便,我们是不是可以继续扩展,将其变成比较合理的:

    <CustomSection>
      <ChildCustomSectionA childId="1" childValue="ChildA"></ChildCustomSectionA>
      <ChildCustomSectionB childid="2" childValue=”ChildB”></ChildCustomSectionB>
    </CustomSection>
          这种方式呢? 我们为<ChildCustomSectionA></ChildCustomSectionA>创建扩展自ConfigurationElement类的子类CustomSectionElementA,然后修改CustomSection类中的Property,使得类型不再是int 或 string,

   而是我们创建的新类  CustomSectionElementA。

    由于ChildCustomSectionA 和ChildCustomSectionB 的结构相对一致,根据面向对象的开发封闭原则,我们可以先抽象出一个base类,然后让ChildCustomSectionA,ChildCustomSectionB分别继承自此base类,

   当以后要添加更多的ChildCustomSectionC,ChildCustomSectionD…时,使用这种Template的设计模式,将更加灵活。


    public abstract class CustomSectionElementBase : System.Configuration.ConfigurationElement
    {
        [ConfigurationProperty("childId", IsRequired = true, IsKey = true)]
        public int ChildID
        {
            get { return (int)base["childId"]; }
            set { base["childId"] = value; }
        }

        [ConfigurationProperty("childValue", IsRequired = true)]
        public string ChildValue
        {
            get { return base["childValue"].ToString(); }
            set { base["childValue"] = value; }
        }
    }

 

    public class CustomSectionElementA : CustomSectionElementBase
    {
        public CustomSectionElementA()
        {
            base.ChildID = 1;
            base.ChildValue = "ChildA";
        }
    }

     
    public class CustomSectionElementB : CustomSectionElementBase
    {
        public CustomSectionElementB()
        {
            base.ChildID = 2;
            base.ChildValue = "ChildB";
        }
    }

     完成了ConfigurationElement的实现,我们可以改写我们上一个例子中定义的CustomSection类了:

    public class CustomSectionWithChildElement : System.Configuration.ConfigurationSection
    {
        private const string elementChildA = "childSectionA";
        private const string elementChildB = "childSectionB";

        [ConfigurationProperty(elementChildA, IsRequired = true, IsKey = true)]
        public CustomSectionElementA ChildSectionA
        {
            get { return base[elementChildA] as CustomSectionElementA; }
            set { base[elementChildA] = value; }
        }

        [ConfigurationProperty(elementChildB, IsRequired = true)]
        public CustomSectionElementB ChildSectionB
        {
            get { return base[elementChildB] as CustomSectionElementB; }
            set { base[elementChildB] = value; }
        }
    }

 
    public class CustomSectionWithChildElementBroker
    {
        private CustomSectionWithChildElement customSection = null;
        public void InsertCustomSection()
        {
            customSection = new CustomSectionWithChildElement();
            customSection.ChildSectionA = new CustomSectionElementA();
            customSection.ChildSectionB = new CustomSectionElementB();

            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            config.Sections.Add("CustomSectionWithChildElement", customSection);
            config.Save(ConfigurationSaveMode.Minimal);
        }

        public int GetCustomSectionChildAID()
        {
            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            CustomSectionWithChildElement cswe = config.GetSection("CustomSectionWithChildElement") as CustomSectionWithChildElement;
            return cswe.ChildSectionA.ChildID;
        }
    }

     将Property改成我们自定义类的形式.测试代码如下:
        public void TestCustomSectionWithChildElement()
        {
            CustomSectionWithChildElementBroker cweb = new CustomSectionWithChildElementBroker();
            cweb.InsertCustomSection();
            Assert.AreEqual(1, cweb.GetCustomSectionChildAID());
        }

     看看运行后我们的app.config变成什么样子了:

<configuration>
  <configSections>
    <section name="CustomSectionWithChildElement" type="Tonnie.Configuration.Library.CustomSectionWithChildElement, Tonnie.Configuration.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    <section name="CustomSection" type="Tonnie.Configuration.Library.CustomSection, Tonnie.Configuration.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    <sectionGroup name="MySectionGroup">
      <section name="MyFirstSection" type="System.Configuration.DictionarySectionHandler"/>
      <section name="MySecondSection" type="System.Configuration.DictionarySectionHandler"/>
    </sectionGroup>
  </configSections>
  <CustomSectionWithChildElement>
    <childSectionA childId="1" childValue="ChildA" />
    <childSectionB childId="2" childValue="ChildB" />
  </CustomSectionWithChildElement>
  <CustomSection sectionId="1" sectionValue="The First Value" />
  <MySectionGroup>
    <MyFirstSection>
      <add key="First" value="First Section"/>
    </MyFirstSection>
    <MySecondSection>
      <add key="Second" value="Second Section"/>
    </MySecondSection>
  </MySectionGroup>
</configuration>

     下面为我们的CustomSectionWithChildElement外面再加一层SectionGroup:

    public class CustomSectionGroup : System.Configuration.ConfigurationSectionGroup
    {
        [ConfigurationProperty("customSectionA", IsRequired = true, IsKey = true)]
        public CustomSectionWithChildElement SectionA
        {
            get { return base.Sections["customSectionA"] as CustomSectionWithChildElement; }
            set
            {
                this.Sections.Add("customSectionA", value);
            }
        }
    }

    public class CustomSectionGroupWithChildElementBroker
    {
        private CustomSectionWithChildElement customSection = null;
        public void InsertCustomSectionGroup()
        {
            customSection = new CustomSectionWithChildElement();
            customSection.ChildSectionA = new CustomSectionElementA();
            customSection.ChildSectionB = new CustomSectionElementB();

            CustomSectionGroup sectionGroup = new CustomSectionGroup();
            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            if (config.GetSectionGroup("customSectionGroup") == null)
                config.SectionGroups.Add("customSectionGroup", sectionGroup);
            sectionGroup.SectionA = customSection;
            config.Save(ConfigurationSaveMode.Minimal);
        }

        public int GetCustomSectionChildAID()
        {
            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            CustomSectionWithChildElement cswe = config.GetSection("customSectionGroup/customSectionA") as CustomSectionWithChildElement;
            return cswe.ChildSectionA.ChildID;
        }
    }

     测试一下:

        public void TestCustomSectionGroupWithChildElement()
        {
            CustomSectionGroupWithChildElementBroker cweb = new CustomSectionGroupWithChildElementBroker();
            cweb.InsertCustomSectionGroup();
            Assert.AreEqual(1, cweb.GetCustomSectionChildAID());
        }
     没问题,看下现在的app.config,是不是更加结构化了:

<configuration>
  <configSections>
    <sectionGroup name="MySectionGroup">
      <section name="MyFirstSection" type="System.Configuration.DictionarySectionHandler"/>
      <section name="MySecondSection" type="System.Configuration.DictionarySectionHandler"/>
    </sectionGroup>
    <sectionGroup name="customSectionGroup" type="Tonnie.Configuration.Library.CustomSectionGroup, Tonnie.Configuration.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" >
      <section name="customSectionA" type="Tonnie.Configuration.Library.CustomSectionWithChildElement, Tonnie.Configuration.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
    </sectionGroup>
  </configSections>
  <MySectionGroup>
    <MyFirstSection>
      <add key="First" value="First Section"/>
    </MyFirstSection>
    <MySecondSection>
      <add key="Second" value="Second Section"/>
    </MySecondSection>
  </MySectionGroup>
  <customSectionGroup>
    <customSectionA>
      <childSectionA childId="1" childValue="ChildA" />
      <childSectionB childId="2" childValue="ChildB" />
    </customSectionA>
  </customSectionGroup>
</configuration>


    以上测试代码是用代码方式修改app.config配置文件,也可以手动添加,2.1内容摘自 http://www.ibeifeng.com/tech.php?id=55401


         2.2.实现IConfigurationSectionHandler接口

 

namespace MyConfigurationTest
{
    public class RobsunParaSectionHandler : IConfigurationSectionHandler
    {
        #region IConfigurationSectionHandler 成員

        public object Create(object parent, object configContext, XmlNode section)
        {
            RobsunPara para = new RobsunPara();

            foreach (XmlNode xn in section.ChildNodes)
            {
                switch (xn.Name)
                {
                    case "path":
                        para.Path = xn.SelectSingleNode("@value").InnerText;
                        break;
                    case "companyName":
                        para.CompanyName = xn.SelectSingleNode("@value").InnerText;
                        break;
                    case "isPrivate":
                        para.IsPrivate = bool.Parse(xn.SelectSingleNode("@attribute").InnerText);
                        break;
                }
            }

            return para;
        }

        #endregion
    }
}

    以上RobsunParaSectionHandler类实现 IConfigurationSectionHandler 接口.


    RobsunPara类(实际就是参数类)的代码如下:

    public class RobsunPara
    {
        #region code
        private string _path = "";
        private string _companyName = "";
        private bool _isPrivate = false;

        public string Path
        {
            get { return _path; }
            set { _path = value; }
        }

        public string CompanyName
        {
            get { return _companyName; }
            set { _companyName = value; }
        }

        public bool IsPrivate
        {
            get { return _isPrivate; }
            set { _isPrivate = value; }
        }
        #endregion
    }

    ConfigurationHander类的创建工作已完成,次handler的工作必须配合如下配置文件的格式(其实的配置文件依赖handler).

    这里是web.config(三种配置文件任一,web.config,App.config,machine.config ,前两种会覆盖machine.config,当然这里是没法子在App.config配置了  )

<configuration>
  <configSections>
    <sectionGroup name="robsunGroup">
      <section name="robsunSection" type="RobsunConfigSectionHandler.RobsunParaSectionHandler,RobsunConfigSectionHandler"/>
    </sectionGroup>
  </configSections>
  <robsunGroup>
    <robsunSection>
      <path value="NONE"/>
      <companyName value="Robsun"/>
      <isPrivate attribute="true"/>
    </robsunSection>
  </robsunGroup>
</configuration>
    以上2.2内容摘自 http://www.cnblogs.com/panshuiqing/articles/1193860.html

抖音无水印视频爬虫实战:从抓包分析到批量下载指定用户作品 抖音作为当前最受欢迎的短视频平台,拥有海量的优质内容。很多用户希望备份自己或他人的作品,但抖音官方并未提供批量下载功能,且直接下载的视频带有平台水印。本文将带领大家从零开始,通过抓包分析、设备模拟、请求签名等核心技术,实现一个完整的抖音无水印视频爬虫系统。本文仅供技术学习和个人备份使用,请勿将爬取的内容用于商业用途或侵犯他人版权,爬取频率请控制合理范围内。目录一、前言二、技术栈概览三、准备工作3.1 环境搭建3.2 抓包分析步骤3.3 关键API发现四、核心技术解密4.1 X-Gorgon签名算法。 阅读详情

相关推荐

双目立体匹配算法:SGBM

SGBM(Semi-Global Block Matching)是一种用于计算双目视觉中视差(disparity)的半全局匹配算法,在OpenCV中的实现为semi-global block matching(SGBM)。它是基于全局匹配算法和局部匹配算法的优缺点,提出了一种折中的方法,既能保证视差图的质量,又能降低计算复杂度。

weixin_45303602的博客 9411

自定义app.config中的section节点以及在运行中的使用

假如现在我们需要在app.config中定义一个如下的节点,我们需要进行怎样的操作? 那么这个节点的各个字段都代表什么意思?section中name指的是你自定义的这个section的名字,type指的是用于接收这个section中相应字段的类,在程序运行的时候CLR会通过反射将各个字段赋值给这个类的对应属性。在这里,list

写代码的蜗牛 6535

逆变器技术解析:DDSRF双解耦在正负序分离中的关键作用

本文深入解析了DDSRF双解耦技术在逆变器正负序分离中的关键作用。通过建立正反旋转坐标系并利用交叉反馈解耦网络,DDSRF能快速、精准地分离电网电压中的正负序分量,从而显著提升锁相环在电网不平衡条件下的精度与系统稳定性,是现代高性能并网逆变器的核心算法之一。

m3n5b7v8c9x的博客 410

C#配置文件configSections详解

一、问题需求: 在项目中经常遇到需要写配置文件地方,目的就是不想在程序中关于一些信息写死,发布的时候只需要修改一下配置文件就可以,不需要每次都修改程序,如项目名称、数据库连接字符串、IP端口之类 的;对于小项目或者服务程序,配置信息可以通过系统自带的appSettings进行配置,但大项目或者配置信息太多,如果都用appSettings来配置就感觉比较杂乱,运维人员在修改配置的时候不好修改,而且如...

weixin_45032957的博客 4142

Trae CN 使用入门指南

【代码】Trae CN 使用入门指南。

weixin_42551921的博客 8769

Keil5安装包别乱下!手把手教你从官网精准下载C51/V960和MDK5,并完成2032年有效注册(避坑网络资源失效)

本文详细介绍了如何从Keil官网安全下载C51 V9.60和MDK5开发环境,并提供2032年有效注册的完整指南。通过验证安装包完整性、自定义安装路径和长期激活方案,帮助开发者避开网络资源陷阱,搭建稳定的STM32开发环境。

weixin_26886855的博客 532

C#配置文件之App.config和.settings

C#配置文件之App.config和.settings C#的Winform下的配置文件可以分为两类:设置文件(.settings)和应用程序配置文件(.config); 应用程序配置文件可以分成:App.config和自定义的.config配置文件 备注:C#下的配置文件都是标准的XML文件。 1. App.config 1.1 创建 创建winform项目之后会自动生成App.config文件,如果默认没有,可以在项目上右键–新建项–应用程序配置文件,命名为App.config。 <?xml ve

yizhou2010的专栏 1万+

【GPT】Coze使用开放平台接口-【7】Dify 比较篇

coze 用于社交,dify 用来内部构建。抛开工作流,机器人,工具,coze 最大的区别在于可以直接发布到社交媒体上。所以,coze 对操作体验上也花了不少功夫,而 dify 就专注在帮助使用者打磨工作流。coze 各个大模块之前可以联动的机制也比较多,所以侧重点各不相同。

非晓为骁的博客 7614

C#文件操作——配置文件

C#常用的配置保存文件

5188

深入GD32/STM32引脚复用:你的JTAG/SWD接口是怎么‘消失’的?一次讲清原理与预防

本文深入解析GD32/STM32调试接口(JTAG/SWD)突然失效的原理与预防措施。通过分析MCU启动流程、引脚复用机制及典型错误代码模式,揭示调试接口'消失'的根本原因,并提供硬件设计检查清单、软件防护代码及开发流程优化方案,帮助开发者有效避免烧录失败问题。

weixin_42532938的博客 369

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

一个web.Config或app.Config自定义段configSections的示例

一个web.Config或app.Config自定义段configSections的示例 越来越觉得,直接用配置文件app.Config或web.Config配置应用系统的运行参数,比自己做一个xml配置文件,简洁方便得多。这两个配置文件不仅有常见的connectionStrings和appSettings,给出了数据库连接或常见的名/值表的定义访问方法,而且提供了自定义段con...

weixin_33737134的博客 182

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

C#各种配置文件使用,操作方法总结

配置文件操作     配置文件一般分为内置配置文和用户自定义配置文件。     内置配置文件包括app.config、web.config、Settings.settings等等。 用户自定义配置文件一般是将配置信息放到XML文件或注册表中,配置信息一般包括程序设置,记录运行信息,保存控件的信息(比如位置,样式)。 一、内置配置文件操作 app.config和web.config操作类似

奔跑的小河 1万+

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

DotNet 项目中App.config出现的编译错误

今天在练习使用nhibernate来开发时,发现项目启动时会提示C# no source available异常,从而导致整个项目无法正常运行。检查了一下,发现原来是app.config出现的错误导致的:           type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>

Leo的专栏 707

c# Configuration System Failed to Initialize Issue

问题是从web的config内容复制到console app的config文件。 原因是, 在app.config文件中,configuration节点内,第一个节点必须是configSections节点 保证配置内容正确的情况下,调整一下顺序就好了。 转载于:https://www.cnblogs.com/coinci/p/6840497.html...

weixin_30859423的博客 377

C# 读取app.config配置文件 节点键值,提示 "配置系统未能初始化" 错误的解决方案

新建C#项目,在app.config中添加了appSettings项,运行时出现"配置系统未能初始化"的错误,MSDN里写到,如果配置文件中包含 configSections 元素,则 configSections 元素必须是 configuration 元素的第一个子元素。",将自己添加的appSettings放到configSections 后,则正常。

dxd0128的专栏 1万+

[C#] 读写App.config配置文件的方法

[C#] 读写App.config配置文件的方法 作者:xieyc   发布:2013-07-14 17:29   字符数:3433   分类:编程   阅读: 42,239 次   4条评论   我们经常会希望在程序中写入一些配置信息,例如版本号,以及数据库的连接字符串等。你可能知道在WinForm应用程序中可以利用Properties.Settings来进行类似的工作,

老菜鸟 1409

C# App.config学习

进入公司一年多来,对配置文件添加了不少参数,但是从未想过这些参数是如何被读取出来的,今天把读取参数的处理看了一下,收获不少。假定有App.config如下 <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="family...

sinolover的专栏 536

.net中app.config的示例

app.config

ztmsimon的博客 677

App.config提示错误“配置系统未能初始化”

解决: "如果配置文件中包含 configSections 元素,则 configSections 元素必须是 configuration 元素的第一个子元素。" 所以它前面如果有connectionStrings或其它节点,必须把connectionStrings放到它的后面。

gdjlc的专栏 7267

App.config:配置系统未能初始化的异常

如上图所示:App.config文件是这样配置的,在后台代码”ISchedulerFactory scheduler = new StdSchedulerFactory();“中抛出了异常 经网上查资料终于发现https://www.cnblogs.com/tianciliangen/p/5977391.html这篇文章,说configSections 元素必须是 con...

diaozhu8194的博客 218

C# App.config 自定义 配置节 出现的问题:配置系统未能初始化

C# 读取app.config配置文件 节点键值,提示 "配置系统未能初始化" 错误的解决方案     新建C#项目,在app.config中添加了appSettings项,运行时出现"配置系统未能初始化"的错误,   MSDN里写到,如果配置文件中包含 configSections 元素,则 configSections 元素必须是 configuration 元素的第一个子元素。",将自己添加...

weixin_33910759的博客 557

C# App.config 自定义 配置节 报错“配置系统未能初始化” 解决方法

App.config,结果运行的时候出现了 "配置系统未能初始化" 的错误.找了半天才发现是下面的原因造成的: "如果配置文件中包含configSections元素,则configSections元素必须是configuration元素的第一个子元素。".如果把appSettings写它前面..就报以上错误 转载于:https://www.cnblogs.com/haight...

weixin_30707875的博客 188

C# 读取app.config配置文件 节点键值,提示 "配置系统未能初始化" 错误的解决方案...

新建C#项目,在app.config中添加了appSettings项,运行时出现"配置系统未能初始化"的错误,MSDN里写到,如果配置文件中包含 configSections 元素,则 configSections 元素必须是 configuration 元素的第一个子元素。",将自己添加的appSettings放到configSections 后,则正常。...

weixin_33978044的博客 178
上一篇: vs2008(C#) IDE 使用之 菜单栏/编辑 (终)
下一篇: PatternLayout中的转换模式(ConversionPattern)标签含义
猴子写代码
博客等级 码龄12年 15粉丝 11原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值