Generics in custom configuration sections
- by Jonn
I tried making a custom configuration class that went on like this:
WatcherServiceInfoSection<TWatcherServiceDetailElement>
where TWatcherServiceDetailElement is a ConfigurationElement inside it.
Now when I call the type in the ConfigSections area of AppConfig I get the error:
An error occurred creating the configuration section handler for WatcherServiceInfo:
Could not load type 'Library.Common.Utilities.ConfigurationHandler.WatcherServiceInfoSection<ASNDPService.Configuration.WatcherServiceDetailElement>' from assembly
Is what I'm doing possible? Can I have generic types in the type attribute for a custom section element?
EDIT
Additionally, how about ConfigurationElementCollection objects? Like in the above example, how could I do a
[ConfigurationProperty("WatcherServiceDetails", IsRequired = true,
IsDefaultCollection = true)]
[ConfigurationCollection(typeof(TWatcherServiceDetailElement), AddItemName = "WatcherServiceDetail")]
public WatcherServiceDetailCollection<TWatcherServiceDetailElement> WatcherServiceDetails
I'm aware that type parameters aren't allowed for attributes and that's what I want to know how to do.