NameTypeConfigurationElementCollection is different with 2.0?

Aug 21, 2007 at 2:30 AM
I noticed the NameTypeConfigurationElementCollection class is changed, it requires two generic types. But we have used this class to create some our own application blocks, and we didn't support the CustomeElementData, is it mandatory to create a simular CustomeElementData?

I don't want to change too much of my original code.
Aug 21, 2007 at 2:20 PM

Indeed, the class has changed. The reason for the change is to ease the creation of custom providers: now, if a provider in the configuration file does not have the "ConfigurationElementType" attribute, the type in this new generic parameter will be assumed.

In order to update your code, you'll need to set this second parameter. If you don't have a configuration element type for custom providers in your blocks, then you can probably use the "base" configuration type for the second parameter; just be aware that if you ever have a custom provider without the aforementioned attribute, you'll get a runtime error.

If you have many such classes, it might help to define your own NameTypeConfigurationElementCollection<T> class and define it as NameTypeConfigurationElementCollection<T> : NameTypeConfigurationElementCollection<T, T>. Your original code would be unmodified, save for the reference to the new type. I haven't tried running this, but it builds.