I set up a global variable:
string DesiredString;
I set up an array of a struct:
struct structProcessCl ass
{
public string Name;
public Type Class;
}
I fill the array:
structProcessCl ass tempProcessClas s;
Type[] MyTypes = Assembly.GetExe cutingAssembly( ).GetTypes();
foreach (Type thisType in MyTypes)
{
if (thisType.BaseT ype.ToString() == "ProcessTrackDa ta.ProcessingCl ass")
{
tempProcessClas s.Class = thisType;
tempProcessClas s.Name = tempStringOut;
ProcessClasses. Add (tempProcessCla ss);
}
}
I determine which class I want and instantiate it:
DesiredString = cmbProcessingTy pe.Text;
foreach (structProcessC lass thisClass in ProcessClasses)
{
if (thisClass.Name == DesiredString)
{
object[] args = new object[4]{DBFFile, NumberOfRecords , fsr, sw};
DesiredClass =
(ProcessingClas s)System.Activa tor.CreateInsta nce(thisClass.C lass, args);
break;
}
}
Later, I call a member of the desired class:
ExcludeRecord = DesiredClass.Pr ocessRecord(Fie lds, StopGet);
Now that you know what I am doing, I can ask my question. This seems to
work just as I expect it to on my machine. But, when I try it on another
machine (which also has framework installed), it never calls the constructor
for my DesiredClass. In other words, the statement
DesiredClass =
(ProcessingClas s)System.Activa tor.CreateInsta nce(thisClass.C lass, args);
does not seem to work. Does anyone know why this does not work on another
machine and how to fix it? Does anyone know of another way to do it.
I do know that once I know the name of the class I can use either an 'if' or
'case' and put in specific calls. But, I would rather not do this because I
am continually creating new classes and I would have to modify the if/case
area each time I added a new class.
string DesiredString;
I set up an array of a struct:
struct structProcessCl ass
{
public string Name;
public Type Class;
}
I fill the array:
structProcessCl ass tempProcessClas s;
Type[] MyTypes = Assembly.GetExe cutingAssembly( ).GetTypes();
foreach (Type thisType in MyTypes)
{
if (thisType.BaseT ype.ToString() == "ProcessTrackDa ta.ProcessingCl ass")
{
tempProcessClas s.Class = thisType;
tempProcessClas s.Name = tempStringOut;
ProcessClasses. Add (tempProcessCla ss);
}
}
I determine which class I want and instantiate it:
DesiredString = cmbProcessingTy pe.Text;
foreach (structProcessC lass thisClass in ProcessClasses)
{
if (thisClass.Name == DesiredString)
{
object[] args = new object[4]{DBFFile, NumberOfRecords , fsr, sw};
DesiredClass =
(ProcessingClas s)System.Activa tor.CreateInsta nce(thisClass.C lass, args);
break;
}
}
Later, I call a member of the desired class:
ExcludeRecord = DesiredClass.Pr ocessRecord(Fie lds, StopGet);
Now that you know what I am doing, I can ask my question. This seems to
work just as I expect it to on my machine. But, when I try it on another
machine (which also has framework installed), it never calls the constructor
for my DesiredClass. In other words, the statement
DesiredClass =
(ProcessingClas s)System.Activa tor.CreateInsta nce(thisClass.C lass, args);
does not seem to work. Does anyone know why this does not work on another
machine and how to fix it? Does anyone know of another way to do it.
I do know that once I know the name of the class I can use either an 'if' or
'case' and put in specific calls. But, I would rather not do this because I
am continually creating new classes and I would have to modify the if/case
area each time I added a new class.