Tag: custom configuration

ConfigurationElementCollection具有许多不同类型的ConfigurationElements

是否可以使CollectionElementCollection具有许多不同类型的CollectionElements,例如: </collection 我有这样的解决方案所需的所有类: class MyCollection : ConfigurationElementCollection { } class MyElement : ConfigurationElement { } class MyType1 : MyElement { } class MyType2 : MyElement { } … etc 但当我启动我的应用程序时,我得到下一个可预测的错误: 无法识别的属性’Type1SpecificProp’。 因为Type1SpecificProp是在MyType1而不是MyElement定义的,特别是如果MyCollection具有下一个方法: protected override ConfigurationElement CreateNewElement() { return new MyElement(); // but I want instantiate not the base class but by a type given } […]