I've got a Control (mySubControl) which inherits from a UserControl (myAbstractControl) which is abstract. Now inside the Designer of mySubControl, there's always an error saying: Can't create instance of myAbstractControl.
I think the VS2010 Designer is trying to use the constructor of the myAbstractControl.
How can I prevent him from resulting in an error ?
This whole thing seems a bit creepy.
Let's see. I have a abstract BaseClass.
[TypeDescriptionProvider(typeof(ConcreteControlProvider))]
public abstract class AbstractControl : UserControl
It has a constructor containing code, which should be used by any inheriting class.
public AbstractControl(SuperVar myImportantSuperVar)
{
myPrivateSuperVar = myImportantSuperVar;
this.Loaded += new System.Windows.RoutedEventHandler(TreatMySuperVar);
}
Besides that, it needs the empty constructor to match the UserControl inheritance
public AbstractControl() {/*You won't really use me*/}
Now when there's a inheriting class (written by evil colleagues).
public partial class ConcreteControl: AbstractControl
It needs its own constructor and doesn't use my very important SuperVar treating method.
public ConcreteControl(SomeOtherVar notMyVar)
{
// Do some useless things here
}
So there are TWO Problems now. Still I don't know why my designer is messing up and additionally my abstract classes construtor, vars and methods are ignored.
I already tried to use TypeDescriptionProviders (overriding GetReflectionType and CreateInstance) as noted in the linked entry, which didn't make difference.
So how can I solve this issues ?