Design and specific code suggestions for reflection and access base class
-
I'm refactoring some code, and I'm trying to figure out if it's best to to access a base class method using reflection, or if I should access the child class. I definitely need to figure out how to access the base class to set up my form with data (see GetProgControl below). Does anyone know how to do this? I should probably be accessing a method in the child class to access the method in the parent class from the child class, since I am refactoring so I can add some child-specific methods later. The parent class will be common across several projects and classes. The child class will be pushing some group box and comboBox info up to the parent's form, with data. The main form is the base class' form, which I get the control of using GetProgControl using reflection below; however this isn't working since I used to do this when the parent class was what I was accessing directly. I've looked at the following links: http://stackoverflow.com/questions/12051/calling-base-constructor-in-c-sharp[^] http://stackoverflow.com/questions/5558868/printout-the-method-name-of-a-derived-class-by-calling-method-of-a-base-class[^] http://stackoverflow.com/questions/2267277/get-private-properties-method-of-base-class-with-reflection[^] My code, which is still set up to access the base class from before instead of the child class, looks like this: frmUseFrm.cs: //in preparation to add tabs to Generic's form (worked fine before generic became parent class)
if (controls[i] == null)
{
try
{
_assembly = Assembly.LoadFrom(programDll);
_type = _assembly.GetType("CrWr.ProgControl"); //problem here?
_objectInstance = Activator.CreateInstance(