Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 使用ConfigurationSection读取自定义配置节时出现问题_C# 4.0 - Fatal编程技术网

C# 4.0 使用ConfigurationSection读取自定义配置节时出现问题

C# 4.0 使用ConfigurationSection读取自定义配置节时出现问题,c#-4.0,C# 4.0,我有这样一个app.config xml <ProcessConfiguration> <Entry> <Type>type1</Type> <folder>folder1</folder> <fileName>filename1</fileName> <Command arguments="arg1">command1</C

我有这样一个app.config xml

 <ProcessConfiguration>
    <Entry>
      <Type>type1</Type>
      <folder>folder1</folder>
      <fileName>filename1</fileName>
      <Command arguments="arg1">command1</Command>
      <history>history1</history>
    </Entry>
    <Entry>
      <Type>type2</Type>
      <folder>folder2</folder>
      <fileName>filename2</fileName>
      <Command arguments="arg2">command2</Command>
      <history>history2</history>
    </Entry>   
  </ProcessConfiguration>

类型1
折叠1
文件名1
命令1
历史1
类型2
折叠2
文件名2
命令2
历史2
我在配置部分也添加了这个

 <configSections>
    <section name="ProcessConfiguration" type="Assembly.namespace, Assemblyname"   
 requirePermission="false" allowDefinition="Everywhere"/>
  </configSections>


但我无法实现configsection,因为我不确定如何处理此处的ConfigurationElementCollection和ConfigurationElement。有人能帮我吗???

对于app.config中的每个条目,您必须使用添加标记

大概是这样的:

<ProcessConfiguration>
    <ConfigurationElementCollectionName> <!-- In your custom config section class -->
        <add>
            <Type>type1</Type>
            <folder>folder1</folder>
            <fileName>filename1</fileName>
            <Command arguments="arg1">command1</Command>
            <history>history1</history>
        </add>
    </ConfigurationElementCollectionName>
</ProcessConfiguration>

类型1
折叠1
文件名1
命令1
历史1

我尝试了link上给出的方法。但是我的XML与这里显示的非常不同。谢谢Maheep。我是新来的,所以无法正确格式化。我们无法读取我提供的XML?这有一些限制吗?大约2-3个月前,我在读了同一篇MSDN文章后也尝试了同样的方法,但没有成功。在查看了当时的各种SO问题后,我发现对于一组设置,我们需要add tag.hmm ok。如果可能的话,您能为我提供一个关于如何为上面显示的XML实现ConfigurationSection、ConfigurationElementCollection和ConfigurationElement类的想法吗。我在尝试这个的时候完全糊涂了。请帮忙