I greet my colleagues, the situation in question is as follows:
public abstract class BaseClass
{
protected BaseClass()
{
}
protected BaseClass(Object parameter) : this()
{
}
}
public class Descendant : BaseClass
{
}
I am trying to call Activator.CreateInstance in the Descendant class, but no constructor was found .
Do I need to explicitly define it in the Descentant class?
The links I used are as follows: BindingFlags.Instance | BindingFlags.NonPublic
Note 1 . I find the AppDomain.CreateInstanceAndUnwrap () application in reality if it should have any effect.
domain.CreateInstanceAndUnwrap(path, typeName, false, BindingFlags.Instance |
BindingFlags.NonPublic, null, new[] { parameter }, null, null);
Note 2 . If I explicitly define a protected constructor in the Descendant class, then it works, but I would like to avoid this if possible.
source
share