Creating a class instance using a string name
Posted on 2008-11-13
I need to create a class using the name of the class as a string variable. [For background: What I want to do is to run a batch process from an XML file. The XML file contains the name of the class, the parameters for the constructor, and then the method(s) to call with its parameter values, in nested XML blocks]. I have a handle on the XML stuff and I know how to call the method, and get its parameter information using Reflection.
But I cant find how to create a class using a name in string format. The solution should also show how I can find the parameter details for the class constructor, so I can typecast the XML element values (string) to the correct type before calling the constructor. I am looking for a Visual Basic code snippet that will show me how to do this.