Hi. I have a generic abstract base class from which I would like to derive from a dynamic type built through reflection.emit. Also I need to customize the derived class default constructor to initialize some fields. To build the default constructor of the derived class correctly I need to obtain the default constructor of the base class and invoke it. The problem is that I'm not being able to get the default constructor from the base class.
An example:
public abstract class Test<T>
{
private T data;
public abstract void Go();
}
public class TestDerive : Test<int>
{
public override void Go()
{
}
}
class Program
{
static void Main(string[] args)
{
ConstructorInfo[] constructors = typeof(Test<>).GetConstructors();
int length = constructors.Length;
}
}
I've tried everything and length is always zero. I don't understand. I've inspected similar cases in the reflector and there's indeed a call to the base constructor of the abstract class. The question is how do I get it to do the same ?