The designer must create an instance of...cannot because the type is declared abstract
I haven't seen the content at urban potato (its down) but Me and Smelch came up with a solution. Form
itself inherits from an abstract class, so what they dont tell you is that its only the 1st level of inheritance that can't be abstract, the 2nd on down can.
From there its simply a matter of having an empty class in the middle and wrapping an #if debug
around the forms declaration and you're good to go. Just be sure to release in release mode and design in debug mode (which is very typical).
You'll get full designer support and a real abstract base class at design (debug) and build (release) time because each time it ends up using your abstract base class.
The full explanation and answer is here
You can solve this using an attribute on your abstract class like the following
[TypeDescriptionProvider(typeof(AbstractControlDescriptionProvider<MyBaseFormEf, Form>))]
This will work for every case where you need it. The AbstractControlDescriptionProvider is below
public class AbstractControlDescriptionProvider<TAbstract, TBase> : TypeDescriptionProvider
{
public AbstractControlDescriptionProvider()
: base(TypeDescriptor.GetProvider(typeof(TAbstract)))
{
}
public override Type GetReflectionType(Type objectType, object instance)
{
if (objectType == typeof(TAbstract))
return typeof(TBase);
return base.GetReflectionType(objectType, instance);
}
public override object CreateInstance(IServiceProvider provider, Type objectType, Type[] argTypes, object[] args)
{
if (objectType == typeof(TAbstract))
objectType = typeof(TBase);
return base.CreateInstance(provider, objectType, argTypes, args);
}
}