如何使用ConfigurationElementCollection实现ConfigurationSection
我试图在项目中实现自定义配置部分,并且不断遇到我不理解的异常。我希望有人可以在这里填空。 我App.config看起来像这样: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="ServicesSection" type="RT.Core.Config.ServicesConfigurationSectionHandler, RT.Core"/> </configSections> <ServicesSection type="RT.Core.Config.ServicesSection, RT.Core"> <Services> <AddService Port="6996" ReportType="File" /> <AddService Port="7001" ReportType="Other" /> </Services> </ServicesSection> </configuration> 我有一个ServiceConfig这样定义的元素: public class ServiceConfig : ConfigurationElement { public ServiceConfig() {} public ServiceConfig(int port, string reportType) { Port = port; ReportType = reportType; …