You should ask yourself how come you first put the names in the database before doing elementary technological research. Now you are asking about invocation… You should think first, make decision later. I don't think this is a good idea.
Basically, you can have a class name, but you should better have a full class name, to make sure you are working with right namespace and right assembly. It's also good to check up assembly signature against the one stored in the database. You see, you have entered in some non-reliable field where the wrong assembly (or a wrong versions) can contain different types with the same names and cases like that.
You can find the type you need by its name using Reflection. This is done using the method
System.Reflection.Assembly.GetType(String)
. Please see:
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx[
^].
The invocation of the type constructor is required to create an instance (of the form, in your case).
You need to find constructor without parameters, get an instance of the class
System.Reflection.ConstructorInfo
(apparently, there can be only one constructor with this signature) and create an instance using its method
System.Reflection.ConstructorInfo.Invoke
.
Please see:
http://msdn.microsoft.com/en-us/library/system.type.aspx[
^],
http://msdn.microsoft.com/en-us/library/h93ya84h.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.reflection.constructorinfo.aspx[
^],
http://msdn.microsoft.com/en-us/library/6ycw1y17.aspx[
^].
Even though it looks conceptually complex, it's surprisingly easy to achieve if you simply read on all of the involved types and method of Reflection in the MSDN articles referenced above and do all steps in the order I explained.
But I want to warn you: you approach might work immediately, but nevertheless, it needs reviewing. You are can get yourself in nightmare when you start modifying the system and support it. All kinds of incompatibilities between versions of software and data in database can haunt you badly. You need to plan for all the scenarios very thoroughly. First of all, revise the whole idea of string class names (or some other code-related entities) in the database. This is potentially serious architecture, needs a serious architect…
Good luck,
—SA