.net 将自定义配置组移动到单独的文件

.net 将自定义配置组移动到单独的文件,.net,handler,custom-configuration,.net,Handler,Custom Configuration,我最近编写了一个相当大的自定义配置组。我很好奇是否可以通过以下方式将此配置移动到单独的文件中: <configuration> <configSections> <sectionGroup name="MyCustomGroup"> <section name="MyCustomSection"/> </sectionGroup> </configSectio

我最近编写了一个相当大的自定义配置组。我很好奇是否可以通过以下方式将此配置移动到单独的文件中:

<configuration>
    <configSections>
        <sectionGroup name="MyCustomGroup">
            <section name="MyCustomSection"/>
        </sectionGroup>
    </configSections>
    <MyCustomGroup file="alt.config" />
</configuration>

这与appSettings的file属性类似。我意识到很可能需要为我的自定义节处理程序创建ConfigurationPropertyAttribute,但是我在这方面找不到任何示例或方向。

据我所知,您无法使用
configSource
属性将整个节组(即
MyCustomGroup
)外部化,但您必须在节级别处理此问题(即
MyCustomSection


马克

你说得对。分区组不能作为一个整体被外部化,但它的分区可以。@marc_-s-太好了,我不知道这是一个如此古老的问题。我只是在谷歌上搜索,发现这是最好的结果!正是我所需要的。
<configuration>
    <configSections>
        <sectionGroup name="MyCustomGroup">
                <section name="MyCustomSection"/>
        </sectionGroup>
    </configSections>
    <MyCustomGroup>    
       <MyCustomSection configSource="externalfile.config" />
    </MyCustomGroup>
</configuration>
<MyCustomSection>
    ... your settings here......
</MyCustomSection>