4

I have an abstract base control BaseControl for which I resolved the non-display of the child forms using the following post.

Now, I have a lot of controls sharing some common properties for which I want to create an intermediate abstract class to regroup the different common properties and force all descendants to implement some other properties.

[TypeDescriptionProvider(typeof(AbstractControlDescriptionProvider<BaseControl, UserControl>))]
public abstract partial class BaseControl : UserControl {
  ...
  ...
  ...
}
 [TypeDescriptionProvider(typeof(AbstractControlDescriptionProvider<BaseControl2, BaseControl>))]
public abstract partial class BaseControl2 : BaseControl {
  ...
  ...
  ...
}

Unfortunately, this doesn't work, the designer complains about not being able to create an instance of abstract class BaseControl2 for my descendant controls.

Any suggestion of how to resolve this?

Community
  • 1
  • 1
neggenbe
  • 1,697
  • 2
  • 24
  • 62

1 Answers1

0

You need to realize how the AbstractControlDescriptionProvider works - if the type is abstract, it replaces it with the non-abstract base type.

You specified an abstract type as the non-abstract base type, so obviously it can't work :)

Luaan
  • 62,244
  • 7
  • 97
  • 116
  • yes, so I tried to replace with the `UserControl` instead of the `BaseControl` but it doesn't work either... – neggenbe Nov 11 '16 at 13:04
  • @neggenbe Well, you'd need to provide a complete piece of code that actually shows your problem to get real help, but note that the `AbstractControlDescriptionProvider` doesn't traverse the type hierarchy - it only deals with one possible abstract class. And `TypeDescriptorProviderAttribute` is inherited, so in most cases you really need to have no more than one in the whole hierarchy - the designer doesn't even see the second type description provider. – Luaan Nov 11 '16 at 13:22