help needed in creating runtime objects
how to create an object whose type is known only at the runtime.
There are a variety of ways.
//If you have the assembly and type as a string and the assembly might not be loaded yet or you need
//to pass parameters to the constructor
ObjectHandle hdl = Activator.CreateInstance(strAssembly, strType);
object obj = hdl.Unwrap();
//If you have the assembly already
object obj = asm.CreateInstance(strType);
//If you need to pass parameters to the constructor
Type type = Type.GetType(strType);
ConstructorInfo ctor = type.GetConstructor(typeArray);
ctor.Invoke(arguments);
There are a variety of others but these are the most commonly used methods.
Michael Taylor - 9/25/06