I'm trying to create an instance of a class at run time. The classes I'm trying to create all inherit from a base class, ConfigMgrObj, and are named ConfigMgr_xxxxxx
e.g. ConfigMgr_Collection
. They all take a special object that I'm calling oController and a string as arguments.
This is the line I'm using to do it, where ClassToGet is a string that contains the name of the class e.g. ConfigMgr_Collection
.
object oNewObject = System.Activator.CreateInstance(null, "StackOverflowNamespace." + ClassToGet, new object[] { oController, ClassToGet });
This throws a TypeLoadException exception. What's up with it?